@cley_faye/boilerplate 3.10.0 → 3.10.1
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/express/logger.js +1 -1
- package/lib/winston.d.ts +14 -0
- package/lib/winston.js +6 -3
- package/package.json +1 -1
package/lib/express/logger.js
CHANGED
|
@@ -53,7 +53,7 @@ const customRouteFormat = (outputTimestamp) => winston_1.default.format.printf((
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
const metaString = JSON.stringify(info.meta);
|
|
56
|
-
const finalMessage = `${info.message} ${metaString === "{}" ? "" : metaString}`;
|
|
56
|
+
const finalMessage = `${info.message.toString()} ${metaString === "{}" ? "" : metaString}`;
|
|
57
57
|
return (0, winston_js_1.prefixOutput)(info.level, finalMessage, outputTimestamp);
|
|
58
58
|
});
|
|
59
59
|
/** Return the default value for route logger is it is set as `true` */
|
package/lib/winston.d.ts
CHANGED
|
@@ -14,8 +14,22 @@ export interface LogConfig {
|
|
|
14
14
|
collapseNodeModules: boolean;
|
|
15
15
|
collapseStacktrace: boolean;
|
|
16
16
|
}
|
|
17
|
+
interface ExtendedErrorFields {
|
|
18
|
+
cause?: Error;
|
|
19
|
+
response?: {
|
|
20
|
+
data?: string | Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
request?: {
|
|
23
|
+
_currentUrl?: string;
|
|
24
|
+
};
|
|
25
|
+
statusCode?: number;
|
|
26
|
+
}
|
|
27
|
+
declare type ExtendedError = Error & ExtendedErrorFields;
|
|
28
|
+
/** Return a string with the full error and stacktrace, including causes */
|
|
29
|
+
export declare const filterError: (error: ExtendedError, collapseStacktrace?: boolean) => string;
|
|
17
30
|
export declare const customFormat: (timestamp?: boolean, collapseStacktrace?: boolean) => Format;
|
|
18
31
|
/** Edit the configuration applied to consoleLogger */
|
|
19
32
|
export declare const setConfig: (config: LogConfig) => void;
|
|
20
33
|
export declare const transports: winston.transports.ConsoleTransportInstance[];
|
|
21
34
|
export declare const consoleLogger: winston.Logger;
|
|
35
|
+
export {};
|
package/lib/winston.js
CHANGED
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.consoleLogger = exports.transports = exports.setConfig = exports.customFormat = exports.prefixOutput = exports.filterStacktrace = void 0;
|
|
32
|
+
exports.consoleLogger = exports.transports = exports.setConfig = exports.customFormat = exports.filterError = exports.prefixOutput = exports.filterStacktrace = void 0;
|
|
33
33
|
const winston_1 = __importDefault(require("winston"));
|
|
34
34
|
// High value because of colorize()
|
|
35
35
|
const LOG_LEVEL_PADDING_SIZE = 10;
|
|
@@ -127,7 +127,7 @@ const addHttpErrorContent = (error) => {
|
|
|
127
127
|
return `HttpError status: ${error.statusCode}`;
|
|
128
128
|
};
|
|
129
129
|
/** Return a string with the full error and stacktrace, including causes */
|
|
130
|
-
const filterError = (error, collapseStacktrace) => {
|
|
130
|
+
const filterError = (error, collapseStacktrace = true) => {
|
|
131
131
|
const resultRows = [];
|
|
132
132
|
let cursor = error;
|
|
133
133
|
let indentLevel = 0;
|
|
@@ -158,6 +158,7 @@ const filterError = (error, collapseStacktrace) => {
|
|
|
158
158
|
}
|
|
159
159
|
return resultRows.join("\n");
|
|
160
160
|
};
|
|
161
|
+
exports.filterError = filterError;
|
|
161
162
|
const getErrorFromTransformable = (info) => {
|
|
162
163
|
if (info instanceof Error)
|
|
163
164
|
return info;
|
|
@@ -175,7 +176,9 @@ const customFormat = (timestamp, collapseStacktrace) => winston_1.default.format
|
|
|
175
176
|
? logConfig.collapseNodeModules || logConfig.collapseStacktrace
|
|
176
177
|
: collapseStacktrace;
|
|
177
178
|
const error = getErrorFromTransformable(info);
|
|
178
|
-
const message = error
|
|
179
|
+
const message = error
|
|
180
|
+
? (0, exports.filterError)(error, effectiveCollapse)
|
|
181
|
+
: info.message.toString();
|
|
179
182
|
return (0, exports.prefixOutput)(info.level, message, effectiveTimestamp);
|
|
180
183
|
});
|
|
181
184
|
exports.customFormat = customFormat;
|