tabletcommand-logger 2.1.0 → 2.2.0
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/build/bunyan-logger.js
CHANGED
|
@@ -4,7 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const bunyan_1 = __importDefault(require("bunyan"));
|
|
7
|
-
function logger(name, filePath, logToConsole) {
|
|
7
|
+
function logger(name, filePath, logToConsole, logToFile) {
|
|
8
|
+
const loggingEnabled = logToConsole === true || logToFile === true;
|
|
9
|
+
if (!loggingEnabled) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
8
12
|
const streams = [];
|
|
9
13
|
if (logToConsole) {
|
|
10
14
|
const cfg = {
|
|
@@ -13,7 +17,7 @@ function logger(name, filePath, logToConsole) {
|
|
|
13
17
|
};
|
|
14
18
|
streams.push(cfg);
|
|
15
19
|
}
|
|
16
|
-
|
|
20
|
+
if (logToFile) {
|
|
17
21
|
const cfg = {
|
|
18
22
|
type: "rotating-file",
|
|
19
23
|
path: filePath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bunyan-logger.js","sourceRoot":"","sources":["../src/bunyan-logger.ts"],"names":[],"mappings":";;;;;AAAA,oDAAwC;AAExC,SAAwB,MAAM,CAAC,IAAY,EAAE,QAAgB,EAAE,YAAqB;
|
|
1
|
+
{"version":3,"file":"bunyan-logger.js","sourceRoot":"","sources":["../src/bunyan-logger.ts"],"names":[],"mappings":";;;;;AAAA,oDAAwC;AAExC,SAAwB,MAAM,CAAC,IAAY,EAAE,QAAgB,EAAE,YAAqB,EAAE,SAAkB;IACtG,MAAM,cAAc,GAAG,YAAY,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI,CAAC;IACnE,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,YAAY,EAAE;QAChB,MAAM,GAAG,GAAW;YAClB,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnB;IACD,IAAI,SAAS,EAAE;QACb,MAAM,GAAG,GAAW;YAClB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,EAAE;SACV,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnB;IAED,MAAM,YAAY,GAAG,gBAAM,CAAC,YAAY,CAAC;QACvC,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;IAEH,gCAAgC;IAChC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACzB,YAAY,CAAC,iBAAiB,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AAnCD,yBAmCC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import bunyan from "bunyan";
|
|
2
|
-
export default function logger(name: string, filePath: string, logToConsole: boolean): bunyan;
|
|
2
|
+
export default function logger(name: string, filePath: string, logToConsole: boolean, logToFile: boolean): bunyan | null;
|
|
3
3
|
export declare type LoggerModule = ReturnType<typeof logger>;
|
|
4
4
|
//# sourceMappingURL=bunyan-logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bunyan-logger.d.ts","sourceRoot":"","sources":["../src/bunyan-logger.ts"],"names":[],"mappings":"AAAA,OAAO,MAAkB,MAAM,QAAQ,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"bunyan-logger.d.ts","sourceRoot":"","sources":["../src/bunyan-logger.ts"],"names":[],"mappings":"AAAA,OAAO,MAAkB,MAAM,QAAQ,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAmCvH;AAED,oBAAY,YAAY,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tabletcommand-logger",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Tablet Command Logging Configuration",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "gulp ts",
|
|
@@ -23,24 +23,24 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/bunyan": "^1.8.8",
|
|
26
|
-
"@types/chai": "^4.3.
|
|
26
|
+
"@types/chai": "^4.3.3",
|
|
27
27
|
"@types/debug": "4.1.7",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
|
-
"@types/express-serve-static-core": "^4.17.
|
|
29
|
+
"@types/express-serve-static-core": "^4.17.30",
|
|
30
30
|
"@types/gulp-copy": "0.0.4",
|
|
31
|
-
"@types/lodash": "^4.14.
|
|
31
|
+
"@types/lodash": "^4.14.184",
|
|
32
32
|
"@types/mocha": "^9.1.1",
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
35
|
-
"@typescript-eslint/parser": "^5.
|
|
33
|
+
"@types/node": "^18.7.15",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
35
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
36
36
|
"chai": "^4.3.6",
|
|
37
37
|
"del": "^6.1.1",
|
|
38
|
-
"eslint": "^8.
|
|
38
|
+
"eslint": "^8.23.0",
|
|
39
39
|
"eslint-config-standard": "^17.0.0",
|
|
40
40
|
"eslint-plugin-import": "^2.26.0",
|
|
41
41
|
"eslint-plugin-mocha-only": "0.0.3",
|
|
42
42
|
"eslint-plugin-node": "^11.1.0",
|
|
43
|
-
"eslint-plugin-promise": "^6.0.
|
|
43
|
+
"eslint-plugin-promise": "^6.0.1",
|
|
44
44
|
"eslint-plugin-security": "^1.5.0",
|
|
45
45
|
"eslint-plugin-standard": "^4.1.0",
|
|
46
46
|
"gulp": "^4.0.2",
|
package/src/bunyan-logger.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import bunyan, { Stream } from "bunyan";
|
|
2
2
|
|
|
3
|
-
export default function logger(name: string, filePath: string, logToConsole: boolean): bunyan {
|
|
3
|
+
export default function logger(name: string, filePath: string, logToConsole: boolean, logToFile: boolean): bunyan | null {
|
|
4
|
+
const loggingEnabled = logToConsole === true || logToFile === true;
|
|
5
|
+
if (!loggingEnabled) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
const streams: Stream[] = [];
|
|
5
10
|
if (logToConsole) {
|
|
6
11
|
const cfg: Stream = {
|
|
@@ -8,7 +13,8 @@ export default function logger(name: string, filePath: string, logToConsole: boo
|
|
|
8
13
|
stream: process.stdout,
|
|
9
14
|
};
|
|
10
15
|
streams.push(cfg);
|
|
11
|
-
}
|
|
16
|
+
}
|
|
17
|
+
if (logToFile) {
|
|
12
18
|
const cfg: Stream = {
|
|
13
19
|
type: "rotating-file",
|
|
14
20
|
path: filePath,
|
|
@@ -17,11 +23,12 @@ export default function logger(name: string, filePath: string, logToConsole: boo
|
|
|
17
23
|
};
|
|
18
24
|
streams.push(cfg);
|
|
19
25
|
}
|
|
26
|
+
|
|
20
27
|
const loggerClient = bunyan.createLogger({
|
|
21
28
|
name,
|
|
22
29
|
streams,
|
|
23
30
|
});
|
|
24
|
-
|
|
31
|
+
|
|
25
32
|
// Reopen file streams on signal
|
|
26
33
|
process.on("SIGUSR2", () => {
|
|
27
34
|
loggerClient.reopenFileStreams();
|