@capytale/activity.js 3.1.12 → 3.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/logger.d.ts +55 -11
- package/api/logger.js +32 -16
- package/api/logger.js.map +1 -1
- package/backend/capytale/logger.d.ts +7 -11
- package/backend/capytale/logger.js +6 -0
- package/backend/capytale/logger.js.map +1 -1
- package/package.json +1 -1
package/api/logger.d.ts
CHANGED
|
@@ -1,12 +1,56 @@
|
|
|
1
1
|
import type { HttpBackend } from "./http/backend";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
interface Report {
|
|
3
|
+
/**
|
|
4
|
+
* Log un message d'information
|
|
5
|
+
*
|
|
6
|
+
* @param message Message à logger
|
|
7
|
+
*/
|
|
8
|
+
notice(...message: string[] | [string[]]): void;
|
|
9
|
+
/**
|
|
10
|
+
* Log un message d'avertissement
|
|
11
|
+
*
|
|
12
|
+
* @param message Message à logger
|
|
13
|
+
*/
|
|
14
|
+
warning(...message: string[] | [string[]]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Log un message d'erreur
|
|
17
|
+
*
|
|
18
|
+
* @param message Message à logger
|
|
19
|
+
*/
|
|
20
|
+
error(...message: string[] | [string[]]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Envoie le rapport
|
|
23
|
+
*
|
|
24
|
+
* @param force Envoie le rapport même s'il est vide
|
|
25
|
+
*/
|
|
26
|
+
send(force?: boolean): void;
|
|
27
|
+
}
|
|
28
|
+
export interface Logger {
|
|
29
|
+
/**
|
|
30
|
+
* Log un message d'information
|
|
31
|
+
*
|
|
32
|
+
* @param message Message à logger
|
|
33
|
+
*/
|
|
34
|
+
notice(...message: string[] | [string[]]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Log un message d'avertissement
|
|
37
|
+
*
|
|
38
|
+
* @param message Message à logger
|
|
39
|
+
*/
|
|
40
|
+
warning(...message: string[] | [string[]]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Log un message d'erreur
|
|
43
|
+
*
|
|
44
|
+
* @param message Message à logger
|
|
45
|
+
*/
|
|
46
|
+
error(...message: string[] | [string[]]): void;
|
|
47
|
+
/**
|
|
48
|
+
* Crée un rapport qui peut être envoyé plus tard
|
|
49
|
+
*
|
|
50
|
+
* @param title Titre du rapport
|
|
51
|
+
* @returns Objet Rapport
|
|
52
|
+
*/
|
|
53
|
+
report(...title: string[] | [string[]]): Report;
|
|
54
|
+
}
|
|
55
|
+
declare const _default: (backend: HttpBackend) => (channel: string) => Logger;
|
|
56
|
+
export default _default;
|
package/api/logger.js
CHANGED
|
@@ -1,37 +1,53 @@
|
|
|
1
1
|
const levels = ['notice', 'warning', 'error'];
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function parseParam(m) {
|
|
3
|
+
if (m.length === 1 && Array.isArray(m[0])) {
|
|
4
|
+
return m[0];
|
|
5
|
+
}
|
|
6
|
+
return m;
|
|
7
|
+
}
|
|
8
|
+
export default (function (backend) {
|
|
9
|
+
return (function (channel) {
|
|
4
10
|
function log(level, message) {
|
|
11
|
+
message = parseParam(message);
|
|
5
12
|
return backend.postJsonAsync('/web/capytale/api/logger', { channel, level: levels[level], message });
|
|
6
13
|
}
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Crée un rapport qui peut être envoyé plus tard
|
|
16
|
+
*
|
|
17
|
+
* @param title Titre du rapport
|
|
18
|
+
* @returns Objet Rapport
|
|
19
|
+
*/
|
|
20
|
+
function report(...title) {
|
|
21
|
+
title = parseParam(title);
|
|
22
|
+
const msg = [];
|
|
9
23
|
let level = 0;
|
|
10
24
|
function add(l, message) {
|
|
25
|
+
message = parseParam(message);
|
|
11
26
|
if (l > level)
|
|
12
27
|
level = l;
|
|
13
|
-
|
|
28
|
+
message = message.map(m => `[${levels[l]}] ${m.trim()}`);
|
|
29
|
+
msg.push(...message);
|
|
14
30
|
}
|
|
15
31
|
function send(force = false) {
|
|
16
|
-
if (!force &&
|
|
32
|
+
if (!force && msg.length === 0)
|
|
17
33
|
return;
|
|
18
|
-
log(level,
|
|
19
|
-
|
|
34
|
+
log(level, [...title, ...msg]);
|
|
35
|
+
msg.length = 0;
|
|
20
36
|
level = 0;
|
|
21
37
|
}
|
|
22
38
|
return {
|
|
23
|
-
notice(message) { add(0, message); },
|
|
24
|
-
warning(message) { add(1, message); },
|
|
25
|
-
error(message) { add(2, message); },
|
|
39
|
+
notice(...message) { add(0, message); },
|
|
40
|
+
warning(...message) { add(1, message); },
|
|
41
|
+
error(...message) { add(2, message); },
|
|
26
42
|
send,
|
|
27
43
|
};
|
|
28
44
|
}
|
|
29
45
|
return {
|
|
30
|
-
notice(message) { log(0, message); },
|
|
31
|
-
warning(message) { log(1, message); },
|
|
32
|
-
error(message) { log(2, message); },
|
|
46
|
+
notice(...message) { log(0, message); },
|
|
47
|
+
warning(...message) { log(1, message); },
|
|
48
|
+
error(...message) { log(2, message); },
|
|
33
49
|
report,
|
|
34
50
|
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
37
53
|
//# sourceMappingURL=logger.js.map
|
package/api/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/api/logger.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAuC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/api/logger.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAuC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAwDlF,SAAS,UAAU,CAAC,CAAwB;IAC1C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI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M,GAAG,CAAC,CAAC;gBACf,KAAK,GAAG,CAAC,CAAC;YACZ,CAAC;YAED,OAAO;gBACL,MAAM,CAAC,GAAG,OAA8B,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC9D,OAAO,CAAC,GAAG,OAA8B,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC/D,KAAK,CAAC,GAAG,OAA8B,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC7D,IAAI;aACL,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,CAAC,GAAG,OAA8B,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAC9D,OAAO,CAAC,GAAG,OAA8B,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAC/D,KAAK,CAAC,GAAG,OAA8B,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAC7D,MAAM;SACG,CAAC;IACd,CAAC,CACF,CAAC;AACJ,CAAC,CACF,CAAA","sourcesContent":["import type { HttpBackend } from \"./http/backend\";\n\nconst levels: ('notice' | 'warning' | 'error')[] = ['notice', 'warning', 'error'];\n\ninterface Report {\n /**\n * Log un message d'information\n * \n * @param message Message à logger\n */\n notice(...message: string[] | [string[]]): void;\n /**\n * Log un message d'avertissement\n * \n * @param message Message à logger\n */\n warning(...message: string[] | [string[]]): void;\n /**\n * Log un message d'erreur\n * \n * @param message Message à logger\n */\n error(...message: string[] | [string[]]): void;\n /**\n * Envoie le rapport\n * \n * @param force Envoie le rapport même s'il est vide\n */\n send(force?: boolean): void;\n}\nexport interface Logger {\n /**\n * Log un message d'information\n * \n * @param message Message à logger\n */\n notice(...message: string[] | [string[]]): void;\n /**\n * Log un message d'avertissement\n * \n * @param message Message à logger\n */\n warning(...message: string[] | [string[]]): void;\n /**\n * Log un message d'erreur\n * \n * @param message Message à logger\n */\n error(...message: string[] | [string[]]): void;\n /**\n * Crée un rapport qui peut être envoyé plus tard\n * \n * @param title Titre du rapport\n * @returns Objet Rapport\n */\n report(...title: string[] | [string[]]): Report;\n}\n\nfunction parseParam(m: string[] | [string[]]): string[] {\n if (m.length === 1 && Array.isArray(m[0])) {\n return m[0];\n }\n return m as string[];\n}\n\n\nexport default (\n function (backend: HttpBackend) {\n return (\n function (channel: string) {\n function log(\n level: 0 | 1 | 2,\n message: string[] | [string[]]): Promise<void> {\n message = parseParam(message);\n return backend.postJsonAsync(\n '/web/capytale/api/logger',\n { channel, level: levels[level], message }\n );\n }\n\n /**\n * Crée un rapport qui peut être envoyé plus tard\n * \n * @param title Titre du rapport\n * @returns Objet Rapport\n */\n function report(...title: string[] | [string[]]) {\n title = parseParam(title);\n const msg: string[] = [];\n let level: 0 | 1 | 2 = 0;\n\n function add(l: 0 | 1 | 2, message: string[] | [string[]]) {\n message = parseParam(message);\n if (l > level) level = l;\n message = message.map(m => `[${levels[l]}] ${m.trim()}`);\n msg.push(...message);\n }\n\n function send(force = false): void {\n if (!force && msg.length === 0) return;\n log(level, [...(title as string[]), ...msg]);\n msg.length = 0;\n level = 0;\n }\n\n return {\n notice(...message: string[] | [string[]]) { add(0, message); },\n warning(...message: string[] | [string[]]) { add(1, message); },\n error(...message: string[] | [string[]]) { add(2, message); },\n send,\n };\n }\n\n return {\n notice(...message: string[] | [string[]]) { log(0, message); },\n warning(...message: string[] | [string[]]) { log(1, message); },\n error(...message: string[] | [string[]]) { log(2, message); },\n report,\n } as Logger;\n }\n );\n }\n)"]}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
error(message: string): void;
|
|
9
|
-
send: (force?: boolean) => void;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Crée un logger pour le canal donné
|
|
3
|
+
*
|
|
4
|
+
* @param channel canal de log
|
|
5
|
+
* @returns objet Logger
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: (channel: string) => import("../../api/logger").Logger;
|
|
12
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/backend/capytale/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,eAAe,SAAS,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import http from \"./http\";\nimport loggerApi from \"../../api/logger\";\n\nexport default loggerApi(http);"]}
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/backend/capytale/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC;;;;;GAKG;AACH,eAAe,SAAS,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import http from \"./http\";\nimport loggerApi from \"../../api/logger\";\n\n/**\n * Crée un logger pour le canal donné\n * \n * @param channel canal de log\n * @returns objet Logger\n */\nexport default loggerApi(http);"]}
|