stentor-logger 1.60.21 → 1.60.22
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/lib/index.d.ts +2 -3
- package/lib/index.js +5 -2
- package/lib/index.js.map +1 -1
- package/lib/logger.d.ts +7 -0
- package/lib/logger.js +40 -9
- package/lib/logger.js.map +1 -1
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.log = void 0;
|
|
3
|
+
exports.log = exports.classLogger = void 0;
|
|
4
4
|
/*! Copyright (c) 2019, XAPPmedia */
|
|
5
5
|
const logger_1 = require("./logger");
|
|
6
|
-
|
|
6
|
+
var logger_2 = require("./logger");
|
|
7
|
+
Object.defineProperty(exports, "classLogger", { enumerable: true, get: function () { return logger_2.classLogger; } });
|
|
8
|
+
var logger_3 = require("./logger");
|
|
9
|
+
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logger_3.log; } });
|
|
7
10
|
exports.default = (0, logger_1.log)();
|
|
8
11
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,qCAA+B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,qCAA+B;AAC/B,mCAAuC;AAA9B,qGAAA,WAAW,OAAA;AAEpB,mCAA+B;AAAtB,6FAAA,GAAG,OAAA;AACZ,kBAAe,IAAA,YAAG,GAAE,CAAC"}
|
package/lib/logger.d.ts
CHANGED
|
@@ -29,3 +29,10 @@ export declare function log(): Logger;
|
|
|
29
29
|
* @param {Logger} logger
|
|
30
30
|
*/
|
|
31
31
|
export declare function set(logger: Logger): void;
|
|
32
|
+
/**
|
|
33
|
+
* Create a class logger that will add the className to the log message.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} className
|
|
36
|
+
* @returns {Logger}
|
|
37
|
+
*/
|
|
38
|
+
export declare function classLogger(className: string): Logger;
|
package/lib/logger.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.redact = redact;
|
|
5
5
|
exports.log = log;
|
|
6
6
|
exports.set = set;
|
|
7
|
+
exports.classLogger = classLogger;
|
|
7
8
|
const stentor_utils_1 = require("stentor-utils");
|
|
8
9
|
const chalk = require("chalk");
|
|
9
10
|
const winston_1 = require("winston");
|
|
@@ -15,7 +16,7 @@ let LOGGER;
|
|
|
15
16
|
function redact(info) {
|
|
16
17
|
// fast pass through check
|
|
17
18
|
if (process.env.OVAI_LOG_PII === "true") {
|
|
18
|
-
console.warn(
|
|
19
|
+
console.warn("OVAI_LOG_PII is now deprecated, please update to use STENTOR_LOG_PII instead.");
|
|
19
20
|
return info;
|
|
20
21
|
}
|
|
21
22
|
if (process.env.STENTOR_LOG_PII === "true") {
|
|
@@ -75,7 +76,14 @@ function log() {
|
|
|
75
76
|
if (!LOGGER) {
|
|
76
77
|
const level = process.env.STENTOR_LOG_LEVEL || process.env.OVAI_LOG_LEVEL || "error";
|
|
77
78
|
LOGGER = (0, winston_1.createLogger)({
|
|
78
|
-
format: winston_1.format.combine((0, winston_1.format)(
|
|
79
|
+
format: winston_1.format.combine((0, winston_1.format)((info) => {
|
|
80
|
+
const allowedClass = process.env.STENTOR_LOG_CLASS;
|
|
81
|
+
const infoClass = info.className;
|
|
82
|
+
if (allowedClass && infoClass !== allowedClass) {
|
|
83
|
+
return false; // skip log
|
|
84
|
+
}
|
|
85
|
+
return info;
|
|
86
|
+
})(), (0, winston_1.format)(redact)(), winston_1.format.prettyPrint(), winston_1.format.splat(), winston_1.format.timestamp(), winston_1.format.printf((info) => {
|
|
79
87
|
if (info.message && info.message.constructor === Object) {
|
|
80
88
|
// for AWS, if you pretty print then it takes up new lines in CloudWatch, which pollutes
|
|
81
89
|
// your log messages so we check to see if we are in a lambda runtime
|
|
@@ -112,19 +120,19 @@ function log() {
|
|
|
112
120
|
else if (typeof info.timestamp === "string") {
|
|
113
121
|
// outside, just print the time mm
|
|
114
122
|
const time = new Date(info.timestamp).toLocaleTimeString([], {
|
|
115
|
-
minute:
|
|
116
|
-
hour:
|
|
117
|
-
second:
|
|
118
|
-
hour12: false
|
|
123
|
+
minute: "2-digit",
|
|
124
|
+
hour: "2-digit",
|
|
125
|
+
second: "2-digit",
|
|
126
|
+
hour12: false,
|
|
119
127
|
});
|
|
120
128
|
return `${lead}|${time}|${info.message}`;
|
|
121
129
|
}
|
|
122
130
|
})),
|
|
123
131
|
transports: [
|
|
124
132
|
new winston_1.transports.Console({
|
|
125
|
-
level
|
|
126
|
-
})
|
|
127
|
-
]
|
|
133
|
+
level,
|
|
134
|
+
}),
|
|
135
|
+
],
|
|
128
136
|
});
|
|
129
137
|
}
|
|
130
138
|
return LOGGER;
|
|
@@ -140,4 +148,27 @@ function log() {
|
|
|
140
148
|
function set(logger) {
|
|
141
149
|
LOGGER = logger;
|
|
142
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Create a class logger that will add the className to the log message.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} className
|
|
155
|
+
* @returns {Logger}
|
|
156
|
+
*/
|
|
157
|
+
function classLogger(className) {
|
|
158
|
+
const base = log();
|
|
159
|
+
const wrap = (level) => {
|
|
160
|
+
return (message, ...meta) => {
|
|
161
|
+
if (typeof message === "object") {
|
|
162
|
+
return base[level](Object.assign(Object.assign({}, message), { className }));
|
|
163
|
+
}
|
|
164
|
+
return base[level](message, ...meta.map((m) => (Object.assign(Object.assign({}, m), { className }))));
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
debug: wrap("debug"),
|
|
169
|
+
info: wrap("info"),
|
|
170
|
+
warn: wrap("warn"),
|
|
171
|
+
error: wrap("error"),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
143
174
|
//# sourceMappingURL=logger.js.map
|
package/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,oCAAoC;;AAyBpC,
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,oCAAoC;;AAyBpC,wBAqDC;AAWD,kBA2EC;AAUD,kBAEC;AAQD,kCAkBC;AAxMD,iDAA6D;AAC7D,+BAAgC;AAEhC,qCAA2D;AAc3D,0BAA0B;AAC1B,IAAI,MAAc,CAAC;AAEnB;;GAEG;AACH,SAAgB,MAAM,CAAC,IAAuB;IAC5C,0BAA0B;IAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,MAAM,EAAE,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;QAC9F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,MAAM,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8CAA8C;IAC9C,MAAM,IAAI,qBAA2B,IAAI,CAAE,CAAC;IAE5C,IAAI,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,KAAK,MAAM,CAAC;IAC/D,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CACV,yGAAyG,CAC1G,CAAC;IACJ,CAAC;IACD,sDAAsD;IACtD,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,CAAC;QAC7C,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,MAAM,CAAC;IAChE,CAAC;IAED,IAAI,OAAO,GAAY,IAAI,CAAC,OAAO,C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C,MAAc;IAChC,MAAM,GAAG,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,SAAiB;IAC3C,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC;IAEnB,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAgB,EAAE;QACjD,OAAO,CAAC,OAAY,EAAE,GAAG,IAAW,EAAE,EAAE;YACtC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC,KAAK,CAAC,iCAAM,OAAO,KAAE,SAAS,IAAG,CAAC;YAChD,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCAAM,CAAC,KAAE,SAAS,IAAG,CAAC,CAAC,CAAC;QACzE,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;KACrB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.60.
|
|
7
|
+
"version": "1.60.22",
|
|
8
8
|
"description": "Simple logging library built on top of Winston for 📣 stentor",
|
|
9
9
|
"types": "lib/index",
|
|
10
10
|
"main": "lib/index",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"mocha": "11.1.0",
|
|
24
24
|
"sinon": "20.0.0",
|
|
25
25
|
"sinon-chai": "3.7.0",
|
|
26
|
-
"stentor-models": "1.60.
|
|
26
|
+
"stentor-models": "1.60.22",
|
|
27
27
|
"ts-node": "10.9.2",
|
|
28
28
|
"typescript": "5.8.3"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"chalk": "4.1.2",
|
|
32
|
-
"stentor-utils": "1.60.
|
|
32
|
+
"stentor-utils": "1.60.22",
|
|
33
33
|
"winston": "3.17.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"clean": "rm -rf ./lib/*",
|
|
38
38
|
"test": "mocha --recursive -r ts-node/register \"./src/**/*.test.ts\""
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "d8dedd1954ad9407a6816d818e4a20729d12a8a8"
|
|
41
41
|
}
|