@xpr/nestjs-slack 0.4.0 → 0.5.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/package.json +1 -1
- package/utils.js +8 -5
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -37,21 +37,24 @@ function messageDecorator(type, pattern) {
|
|
|
37
37
|
})(target, key, descriptor);
|
|
38
38
|
}
|
|
39
39
|
function adjustLogger(logger) {
|
|
40
|
-
//
|
|
40
|
+
// this patch required to support NestJS logger that not use the standard "info"
|
|
41
|
+
// and use "log" instead
|
|
42
|
+
if (logger["log"] && !logger["info"]) {
|
|
43
|
+
logger["info"] = logger["log"].bind(logger);
|
|
44
|
+
}
|
|
45
|
+
// minimal logger interface required by @slack/bolt library
|
|
41
46
|
for (const method of ["debug", "info", "warn", "error"]) {
|
|
42
47
|
if (typeof logger[method] !== "function") {
|
|
43
48
|
throw new Error(`Logger must implement "${method}" method`);
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
|
-
const noop = () => {
|
|
47
|
-
};
|
|
48
51
|
return Object.assign(logger, {
|
|
49
52
|
setLevel(_) {
|
|
50
53
|
// don't allow library to set the level
|
|
51
54
|
},
|
|
52
55
|
setName(name) {
|
|
53
|
-
// setContext
|
|
54
|
-
(logger.setName ?? logger.setContext ??
|
|
56
|
+
// search for all possible setName/setContext methods, use "noop" if none
|
|
57
|
+
(logger.setName ?? logger.setContext ?? ((i) => i))(name);
|
|
55
58
|
},
|
|
56
59
|
getLevel() {
|
|
57
60
|
// always return the lowest supported level (by library, not real logger)
|