@villedemontreal/logger 6.5.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/LICENSE +22 -0
- package/README.md +164 -0
- package/dist/src/config/configs.d.ts +118 -0
- package/dist/src/config/configs.js +167 -0
- package/dist/src/config/configs.js.map +1 -0
- package/dist/src/config/constants.d.ts +60 -0
- package/dist/src/config/constants.js +60 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/consoleStream.d.ts +8 -0
- package/dist/src/consoleStream.js +29 -0
- package/dist/src/consoleStream.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lazyLogger.d.ts +21 -0
- package/dist/src/lazyLogger.js +46 -0
- package/dist/src/lazyLogger.js.map +1 -0
- package/dist/src/logger.d.ts +169 -0
- package/dist/src/logger.js +501 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/logger.test.d.ts +8 -0
- package/dist/src/logger.test.js +564 -0
- package/dist/src/logger.test.js.map +1 -0
- package/package.json +67 -0
- package/src/config/configs.ts +195 -0
- package/src/config/constants.ts +78 -0
- package/src/consoleStream.ts +29 -0
- package/src/index.ts +3 -0
- package/src/lazyLogger.ts +50 -0
- package/src/logger.test.ts +673 -0
- package/src/logger.ts +551 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = exports.isInited = exports.createLogger = exports.setGlobalLogLevel = exports.initLogger = exports.convertLogLevelToPinoNumberLevel = exports.convertLogLevelToPinoLabelLevel = exports.convertPinoLevelToNumber = void 0;
|
|
4
|
+
const general_utils_1 = require("@villedemontreal/general-utils");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const http = require("http");
|
|
7
|
+
const _ = require("lodash");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const pino = require("pino");
|
|
10
|
+
const pinoMultiStreams = require("pino-multi-stream");
|
|
11
|
+
const constants_1 = require("./config/constants");
|
|
12
|
+
const createRotatingFileStream = require('rotating-file-stream').createStream;
|
|
13
|
+
// ==========================================
|
|
14
|
+
// We export the LogLevel
|
|
15
|
+
// ==========================================
|
|
16
|
+
var general_utils_2 = require("@villedemontreal/general-utils");
|
|
17
|
+
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return general_utils_2.LogLevel; } });
|
|
18
|
+
// ==========================================
|
|
19
|
+
// This allows us to get the *TypeScript*
|
|
20
|
+
// informations instead of the ones from the
|
|
21
|
+
// transpiled Javascript file.
|
|
22
|
+
// ==========================================
|
|
23
|
+
require('source-map-support').install({
|
|
24
|
+
environment: 'node'
|
|
25
|
+
});
|
|
26
|
+
// ==========================================
|
|
27
|
+
// App infos
|
|
28
|
+
// ==========================================
|
|
29
|
+
const packageJson = require(`${constants_1.constants.appRoot}/package.json`);
|
|
30
|
+
const appName = packageJson.name;
|
|
31
|
+
const appVersion = packageJson.version;
|
|
32
|
+
let loggerInstance;
|
|
33
|
+
let loggerConfigs;
|
|
34
|
+
let libIsInited = false;
|
|
35
|
+
// Keeping track of all created loggers
|
|
36
|
+
const loggerChildren = [];
|
|
37
|
+
let multistream;
|
|
38
|
+
/**
|
|
39
|
+
* Converts a Pino level to its number value.
|
|
40
|
+
*/
|
|
41
|
+
exports.convertPinoLevelToNumber = (pinoLogLevel) => {
|
|
42
|
+
return pino.levels.values[pinoLogLevel];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Converts a local LogLevel to a Pino label level.
|
|
46
|
+
*/
|
|
47
|
+
exports.convertLogLevelToPinoLabelLevel = (logLevel) => {
|
|
48
|
+
let pinoLevel = 'error';
|
|
49
|
+
if (logLevel !== undefined) {
|
|
50
|
+
if (logLevel === general_utils_1.LogLevel.DEBUG) {
|
|
51
|
+
pinoLevel = 'debug';
|
|
52
|
+
}
|
|
53
|
+
else if (logLevel === general_utils_1.LogLevel.INFO) {
|
|
54
|
+
pinoLevel = 'info';
|
|
55
|
+
}
|
|
56
|
+
else if (logLevel === general_utils_1.LogLevel.WARNING) {
|
|
57
|
+
pinoLevel = 'warn';
|
|
58
|
+
}
|
|
59
|
+
else if (logLevel === general_utils_1.LogLevel.ERROR) {
|
|
60
|
+
pinoLevel = 'error';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return pinoLevel;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Converts a local LogLevel to a Pino number level.
|
|
67
|
+
*/
|
|
68
|
+
exports.convertLogLevelToPinoNumberLevel = (logLevel) => {
|
|
69
|
+
return exports.convertPinoLevelToNumber(exports.convertLogLevelToPinoLabelLevel(logLevel));
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Gets the path to the directory where to log, if required
|
|
73
|
+
*/
|
|
74
|
+
const getLogDirPath = (loggerConfig) => {
|
|
75
|
+
let logDir = loggerConfig.getLogDirectory();
|
|
76
|
+
if (!path.isAbsolute(logDir)) {
|
|
77
|
+
logDir = path.join(process.cwd(), logDir);
|
|
78
|
+
}
|
|
79
|
+
logDir = path.normalize(logDir);
|
|
80
|
+
if (!fs.existsSync(logDir)) {
|
|
81
|
+
fs.mkdirSync(logDir);
|
|
82
|
+
}
|
|
83
|
+
return logDir;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Initialize the logger with the config given in parameter
|
|
87
|
+
* This function must be used before using createLogger or Logger Class
|
|
88
|
+
* @param {LoggerConfigs} loggerConfig
|
|
89
|
+
* @param {string} [name='default']
|
|
90
|
+
* @param force if `true`, the logger will be initialized
|
|
91
|
+
* again even if it already is.
|
|
92
|
+
*/
|
|
93
|
+
exports.initLogger = (loggerConfig, name = 'default', force = false) => {
|
|
94
|
+
if (loggerInstance && !force) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const streams = [];
|
|
98
|
+
loggerConfigs = loggerConfig;
|
|
99
|
+
// ==========================================
|
|
100
|
+
// Logs to stdout, potentially in a human friendly
|
|
101
|
+
// format...
|
|
102
|
+
// ==========================================
|
|
103
|
+
if (loggerConfig.isLogHumanReadableinConsole()) {
|
|
104
|
+
const prettyStream = pinoMultiStreams.prettyStream();
|
|
105
|
+
streams.push({
|
|
106
|
+
level: exports.convertLogLevelToPinoLabelLevel(loggerConfig.getLogLevel()),
|
|
107
|
+
stream: prettyStream
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
streams.push({
|
|
112
|
+
level: exports.convertLogLevelToPinoLabelLevel(loggerConfig.getLogLevel()),
|
|
113
|
+
stream: process.stdout
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// ==========================================
|
|
117
|
+
// Logs in a file too?
|
|
118
|
+
// ==========================================
|
|
119
|
+
if (loggerConfig.isLogToFile()) {
|
|
120
|
+
const rotatingFilesStream = createRotatingFileStream('application.log', {
|
|
121
|
+
path: getLogDirPath(loggerConfig),
|
|
122
|
+
size: loggerConfig.getLogRotateThresholdMB() + 'M',
|
|
123
|
+
maxSize: loggerConfig.getLogRotateMaxTotalSizeMB() + 'M',
|
|
124
|
+
maxFiles: loggerConfig.getLogRotateFilesNbr()
|
|
125
|
+
});
|
|
126
|
+
// ==========================================
|
|
127
|
+
// TODO
|
|
128
|
+
// Temp console logs, to help debug this issue:
|
|
129
|
+
// https://github.com/iccicci/rotating-file-stream/issues/17#issuecomment-384423230
|
|
130
|
+
// ==========================================
|
|
131
|
+
rotatingFilesStream.on('error', (err) => {
|
|
132
|
+
// tslint:disable-next-line:no-console
|
|
133
|
+
console.log('Rotating File Stream error: ', err);
|
|
134
|
+
});
|
|
135
|
+
rotatingFilesStream.on('warning', (err) => {
|
|
136
|
+
// tslint:disable-next-line:no-console
|
|
137
|
+
console.log('Rotating File Stream warning: ', err);
|
|
138
|
+
});
|
|
139
|
+
streams.push({
|
|
140
|
+
level: exports.convertLogLevelToPinoLabelLevel(loggerConfig.getLogLevel()),
|
|
141
|
+
stream: rotatingFilesStream
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
multistream = pinoMultiStreams.multistream(streams);
|
|
145
|
+
loggerInstance = pino({
|
|
146
|
+
name,
|
|
147
|
+
safe: true,
|
|
148
|
+
timestamp: pino.stdTimeFunctions.isoTime,
|
|
149
|
+
messageKey: 'msg',
|
|
150
|
+
level: exports.convertLogLevelToPinoLabelLevel(loggerConfig.getLogLevel())
|
|
151
|
+
}, multistream);
|
|
152
|
+
libIsInited = true;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Change the global log level of the application. Useful to change dynamically
|
|
156
|
+
* the log level of something that is already started.
|
|
157
|
+
* @param level The log level to set for the application
|
|
158
|
+
*/
|
|
159
|
+
exports.setGlobalLogLevel = (level) => {
|
|
160
|
+
if (!loggerInstance) {
|
|
161
|
+
throw new Error('You must use "initLogger" function in @villemontreal/core-utils-logger-nodejs-lib package before making new instance of Logger class.');
|
|
162
|
+
}
|
|
163
|
+
// Change the log level and update children accordingly
|
|
164
|
+
loggerInstance.level = exports.convertLogLevelToPinoLabelLevel(level);
|
|
165
|
+
for (const logger of loggerChildren) {
|
|
166
|
+
logger.update();
|
|
167
|
+
}
|
|
168
|
+
// ==========================================
|
|
169
|
+
// The streams's levels need to be modified too.
|
|
170
|
+
// ==========================================
|
|
171
|
+
if (multistream && multistream.streams) {
|
|
172
|
+
for (const stream of multistream.streams) {
|
|
173
|
+
// We need to use the *numerical* level value here
|
|
174
|
+
stream.level = exports.convertLogLevelToPinoNumberLevel(level);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Shorthands function that return a new logger instance
|
|
180
|
+
* Internally, we use the same logger instance but with different context like the name given in parameter
|
|
181
|
+
* and this context is kept in this new instance returned.
|
|
182
|
+
* @export
|
|
183
|
+
* @param {string} name
|
|
184
|
+
* @returns {ILogger}
|
|
185
|
+
*/
|
|
186
|
+
function createLogger(name) {
|
|
187
|
+
return new Logger(name);
|
|
188
|
+
}
|
|
189
|
+
exports.createLogger = createLogger;
|
|
190
|
+
function isInited() {
|
|
191
|
+
return libIsInited;
|
|
192
|
+
}
|
|
193
|
+
exports.isInited = isInited;
|
|
194
|
+
/**
|
|
195
|
+
* Logger implementation.
|
|
196
|
+
*/
|
|
197
|
+
class Logger {
|
|
198
|
+
/**
|
|
199
|
+
* Creates a logger.
|
|
200
|
+
*
|
|
201
|
+
* @param the logger name. This name should be related
|
|
202
|
+
* to the file the logger is created in. On a production
|
|
203
|
+
* environment, it's possible that only this name will
|
|
204
|
+
* be available to locate the source of the log.
|
|
205
|
+
* Streams will be created after the first call to the logger
|
|
206
|
+
*/
|
|
207
|
+
constructor(name) {
|
|
208
|
+
if (!loggerInstance) {
|
|
209
|
+
throw new Error('You must use "initLogger" function in @villemontreal/core-utils-logger-nodejs-lib package before making new instance of Logger class.');
|
|
210
|
+
}
|
|
211
|
+
this.pino = loggerInstance.child({ name });
|
|
212
|
+
loggerChildren.push(this);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Logs a DEBUG level message object.
|
|
216
|
+
*
|
|
217
|
+
* If the extra "txtMsg" parameter is set, it is
|
|
218
|
+
* going to be added to messageObj as a ".msg"
|
|
219
|
+
* property (if messageObj is an object) or
|
|
220
|
+
* concatenated to messageObj (if it's not an
|
|
221
|
+
* object).
|
|
222
|
+
*
|
|
223
|
+
* Those types of logs are possible :
|
|
224
|
+
*
|
|
225
|
+
* - log.debug("a simple text message");
|
|
226
|
+
* - log.debug({"name": "an object"});
|
|
227
|
+
* - log.debug({"name": "an object..."}, "... and an extra text message");
|
|
228
|
+
* - log.debug(err, "a catched error and an explanation message");
|
|
229
|
+
*/
|
|
230
|
+
debug(messageObj, txtMsg) {
|
|
231
|
+
this.log(general_utils_1.LogLevel.DEBUG, messageObj, txtMsg);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Logs an INFO level message.
|
|
235
|
+
*
|
|
236
|
+
* If the extra "txtMsg" parameter is set, it is
|
|
237
|
+
* going to be added to messageObj as a ".msg"
|
|
238
|
+
* property (if messageObj is an object) or
|
|
239
|
+
* concatenated to messageObj (if it's not an
|
|
240
|
+
* object).
|
|
241
|
+
*
|
|
242
|
+
* Those types of logs are possible :
|
|
243
|
+
*
|
|
244
|
+
* - log.info("a simple text message");
|
|
245
|
+
* - log.info({"name": "an object"});
|
|
246
|
+
* - log.info({"name": "an object..."}, "... and an extra text message");
|
|
247
|
+
* - log.info(err, "a catched error and an explanation message");public
|
|
248
|
+
*/
|
|
249
|
+
info(messageObj, txtMsg) {
|
|
250
|
+
this.log(general_utils_1.LogLevel.INFO, messageObj, txtMsg);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Logs a WARNING level message.
|
|
254
|
+
*
|
|
255
|
+
* If the extra "txtMsg" parameter is set, it is
|
|
256
|
+
* going to be added to messageObj as a ".msg"
|
|
257
|
+
* property (if messageObj is an object) or
|
|
258
|
+
* concatenated to messageObj (if it's not an
|
|
259
|
+
* object).
|
|
260
|
+
*
|
|
261
|
+
* Those types of logs are possible :
|
|
262
|
+
*
|
|
263
|
+
* - log.warning("a simple text message");
|
|
264
|
+
* - log.warning({"name": "an object"});
|
|
265
|
+
* - log.warning({"name": "an object..."}, "... and an extra text message");
|
|
266
|
+
* - log.warning(err, "a catched error and an explanation mespublic sage");
|
|
267
|
+
*/
|
|
268
|
+
warning(messageObj, txtMsg) {
|
|
269
|
+
this.log(general_utils_1.LogLevel.WARNING, messageObj, txtMsg);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Logs an ERROR level message.
|
|
273
|
+
*
|
|
274
|
+
* If the extra "txtMsg" parameter is set, it is
|
|
275
|
+
* going to be added to messageObj as a ".msg"
|
|
276
|
+
* property (if messageObj is an object) or
|
|
277
|
+
* concatenated to messageObj (if it's not an
|
|
278
|
+
* object).
|
|
279
|
+
*
|
|
280
|
+
* Those types of logs are possible :
|
|
281
|
+
*
|
|
282
|
+
* - log.error("a simple text message");
|
|
283
|
+
* - log.error({"name": "an object"});
|
|
284
|
+
* - log.error({"name": "an object..."}, "... and an extra text message");
|
|
285
|
+
* - log.error(err, "a catched error and an explanatpublic ion message");
|
|
286
|
+
*/
|
|
287
|
+
error(messageObj, txtMsg) {
|
|
288
|
+
this.log(general_utils_1.LogLevel.ERROR, messageObj, txtMsg);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Logs a level specific message.
|
|
292
|
+
*
|
|
293
|
+
* If the extra "txtMsg" parameter is set, it is
|
|
294
|
+
* going to be added to messageObj as a ".msg"
|
|
295
|
+
* property (if messageObj is an object) or
|
|
296
|
+
* concatenated to messageObj (if it's not an
|
|
297
|
+
* object).
|
|
298
|
+
*
|
|
299
|
+
* Those types of logs are possible :
|
|
300
|
+
*
|
|
301
|
+
* - log(LogLevel.XXXXX, "a simple text message");
|
|
302
|
+
* - log({"name": "an object"});
|
|
303
|
+
* - log({"name": "an object..."}, "... and an extra text message");
|
|
304
|
+
* - log(err, "a catched error and an epublic xplanation message");
|
|
305
|
+
*/
|
|
306
|
+
// tslint:disable-next-line:cyclomatic-complexity
|
|
307
|
+
log(level, messageObj, txtMsg) {
|
|
308
|
+
let messageObjClean = messageObj;
|
|
309
|
+
const txtMsgClean = txtMsg;
|
|
310
|
+
if (messageObjClean === null || messageObjClean === undefined) {
|
|
311
|
+
messageObjClean = {};
|
|
312
|
+
}
|
|
313
|
+
else if (_.isArray(messageObjClean)) {
|
|
314
|
+
try {
|
|
315
|
+
loggerInstance.error(`The message object to log can't be an array. An object will be used instead and` +
|
|
316
|
+
`the content of the array will be moved to an "_arrayMsg" property on it : ${messageObjClean}`);
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
// too bad
|
|
320
|
+
}
|
|
321
|
+
messageObjClean = {
|
|
322
|
+
_arrayMsg: _.cloneDeep(messageObjClean)
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (general_utils_1.utils.isObjectStrict(messageObjClean)) {
|
|
326
|
+
// ==========================================
|
|
327
|
+
// The underlying logger may ignore all fields
|
|
328
|
+
// except "message" if
|
|
329
|
+
// the message object is an instance of the
|
|
330
|
+
// native "Error" class. But we may want to use
|
|
331
|
+
// that Error class to log more fields. For example :
|
|
332
|
+
//
|
|
333
|
+
// let error: any = new Error("my message");
|
|
334
|
+
// error.customKey1 = "value1";
|
|
335
|
+
// error.customKey2 = "value2";
|
|
336
|
+
// throw error;
|
|
337
|
+
//
|
|
338
|
+
// This is useful if we need a *stackTrace*, which
|
|
339
|
+
// the Error class allows.
|
|
340
|
+
//
|
|
341
|
+
// This is why we create a plain object from that Error
|
|
342
|
+
// object.
|
|
343
|
+
// ==========================================
|
|
344
|
+
if (messageObjClean instanceof Error) {
|
|
345
|
+
const messageObjNew = {};
|
|
346
|
+
messageObjNew.name = messageObj.name;
|
|
347
|
+
messageObjNew.msg = messageObj.message;
|
|
348
|
+
messageObjNew.stack = messageObj.stack;
|
|
349
|
+
// Some extra custom properties?
|
|
350
|
+
messageObjClean = _.assignIn(messageObjNew, messageObj);
|
|
351
|
+
}
|
|
352
|
+
else if (messageObjClean instanceof http.IncomingMessage && messageObjClean.socket) {
|
|
353
|
+
// ==========================================
|
|
354
|
+
// This is a weird case!
|
|
355
|
+
// When logging an Express Request, Pino transforms
|
|
356
|
+
// it first: https://github.com/pinojs/pino-std-serializers/blob/master/lib/req.js#L65
|
|
357
|
+
// But doing so it accesses the `connection.remoteAddress` prpperty
|
|
358
|
+
// and, in some contexts, the simple fact to access this property
|
|
359
|
+
// throws an error:
|
|
360
|
+
// "TypeError: Illegal invocation\n at Socket._getpeername (net.js:712:30)"
|
|
361
|
+
//
|
|
362
|
+
// The workaround is to access this property in a try/catch
|
|
363
|
+
// and, if an error occures, force its value to
|
|
364
|
+
// a simple string.
|
|
365
|
+
// ==========================================
|
|
366
|
+
messageObjClean = _.cloneDeep(messageObjClean);
|
|
367
|
+
try {
|
|
368
|
+
// tslint:disable-next-line:no-unused-expression
|
|
369
|
+
messageObjClean.socket.remoteAddress;
|
|
370
|
+
}
|
|
371
|
+
catch (err) {
|
|
372
|
+
messageObjClean.socket = Object.assign(Object.assign({}, messageObjClean.socket), { remoteAddress: '[not available]' });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
messageObjClean = _.cloneDeep(messageObjClean);
|
|
377
|
+
}
|
|
378
|
+
// ==========================================
|
|
379
|
+
// Pino will always use the "msg" preoperty of
|
|
380
|
+
// the object if it exists, even if we pass a
|
|
381
|
+
// second parameter consisting in the message.
|
|
382
|
+
// ==========================================
|
|
383
|
+
if (txtMsgClean) {
|
|
384
|
+
messageObjClean.msg = (messageObjClean.msg ? messageObjClean.msg + ' - ' : '') + txtMsgClean;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
messageObjClean = {
|
|
389
|
+
msg: messageObjClean + (txtMsgClean ? ` - ${txtMsgClean}` : '')
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
if (level === general_utils_1.LogLevel.DEBUG) {
|
|
393
|
+
this.pino.debug(this.enhanceLog(messageObjClean));
|
|
394
|
+
}
|
|
395
|
+
else if (level === general_utils_1.LogLevel.INFO) {
|
|
396
|
+
this.pino.info(this.enhanceLog(messageObjClean));
|
|
397
|
+
}
|
|
398
|
+
else if (level === general_utils_1.LogLevel.WARNING) {
|
|
399
|
+
this.pino.warn(this.enhanceLog(messageObjClean));
|
|
400
|
+
}
|
|
401
|
+
else if (level === general_utils_1.LogLevel.ERROR) {
|
|
402
|
+
this.pino.error(this.enhanceLog(messageObjClean));
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
try {
|
|
406
|
+
loggerInstance.error(`UNMANAGED LEVEL "${level}"`);
|
|
407
|
+
}
|
|
408
|
+
catch (err) {
|
|
409
|
+
// too bad
|
|
410
|
+
}
|
|
411
|
+
this.pino.error(this.enhanceLog(messageObjClean));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Update the logger based on the parent changes.
|
|
416
|
+
* Could use something more precise to handle specific event but
|
|
417
|
+
* people could use it to update the child independently from the parent,
|
|
418
|
+
* which is not what is intended.
|
|
419
|
+
*/
|
|
420
|
+
update() {
|
|
421
|
+
// Set new level
|
|
422
|
+
this.pino.level = loggerInstance.level;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Adds the file and line number where the log occures.
|
|
426
|
+
* This particular code is required since our custom Logger
|
|
427
|
+
* is a layer over Pino and therefore adds an extra level
|
|
428
|
+
* to the error stack. Without this code, the file and line number
|
|
429
|
+
* are not the right ones.
|
|
430
|
+
*
|
|
431
|
+
* Based by http://stackoverflow.com/a/38197778/843699
|
|
432
|
+
*/
|
|
433
|
+
enhanceLog(messageObj) {
|
|
434
|
+
// ==========================================
|
|
435
|
+
// Adds a property to indicate this is a
|
|
436
|
+
// Montreal type of log entry.
|
|
437
|
+
//
|
|
438
|
+
// TODO validate this + adds standardized
|
|
439
|
+
// properties.
|
|
440
|
+
// ==========================================
|
|
441
|
+
if (!(constants_1.constants.logging.properties.LOG_TYPE in messageObj)) {
|
|
442
|
+
messageObj[constants_1.constants.logging.properties.LOG_TYPE] = constants_1.constants.logging.logType.MONTREAL;
|
|
443
|
+
// ==========================================
|
|
444
|
+
// TO UPDATE when the properties added to the
|
|
445
|
+
// log change!
|
|
446
|
+
//
|
|
447
|
+
// 1 : first version with Bunyan
|
|
448
|
+
// 2 : With Pino
|
|
449
|
+
// ==========================================
|
|
450
|
+
messageObj[constants_1.constants.logging.properties.LOG_TYPE_VERSION] = '2';
|
|
451
|
+
}
|
|
452
|
+
// ==========================================
|
|
453
|
+
// cid : correlation id
|
|
454
|
+
// ==========================================
|
|
455
|
+
const cid = loggerConfigs.correlationId;
|
|
456
|
+
if (cid) {
|
|
457
|
+
messageObj[constants_1.constants.logging.properties.CORRELATION_ID] = cid;
|
|
458
|
+
}
|
|
459
|
+
// ==========================================
|
|
460
|
+
// "app" and "version"
|
|
461
|
+
// @see https://sticonfluence.interne.montreal.ca/pages/viewpage.action?pageId=43530740
|
|
462
|
+
// ==========================================
|
|
463
|
+
messageObj[constants_1.constants.logging.properties.APP_NAME] = appName;
|
|
464
|
+
messageObj[constants_1.constants.logging.properties.APP_VERSION] = appVersion;
|
|
465
|
+
if (!loggerConfigs.isLogSource()) {
|
|
466
|
+
return messageObj;
|
|
467
|
+
}
|
|
468
|
+
let stackLine;
|
|
469
|
+
const stackLines = new Error().stack.split('\n');
|
|
470
|
+
stackLines.shift();
|
|
471
|
+
for (const stackLineTry of stackLines) {
|
|
472
|
+
if (stackLineTry.indexOf(`at ${Logger.name}.`) <= 0) {
|
|
473
|
+
stackLine = stackLineTry;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (!stackLine) {
|
|
478
|
+
return messageObj;
|
|
479
|
+
}
|
|
480
|
+
let callerLine = '';
|
|
481
|
+
if (stackLine.indexOf(')') >= 0) {
|
|
482
|
+
callerLine = stackLine.slice(stackLine.lastIndexOf('/'), stackLine.lastIndexOf(')'));
|
|
483
|
+
if (callerLine.length === 0) {
|
|
484
|
+
callerLine = stackLine.slice(stackLine.lastIndexOf('('), stackLine.lastIndexOf(')'));
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
callerLine = stackLine.slice(stackLine.lastIndexOf('at ') + 2);
|
|
489
|
+
}
|
|
490
|
+
const firstCommaPos = callerLine.lastIndexOf(':', callerLine.lastIndexOf(':') - 1);
|
|
491
|
+
const filename = callerLine.slice(1, firstCommaPos);
|
|
492
|
+
const lineNo = callerLine.slice(firstCommaPos + 1, callerLine.indexOf(':', firstCommaPos + 1));
|
|
493
|
+
messageObj.src = {
|
|
494
|
+
file: filename,
|
|
495
|
+
line: lineNo
|
|
496
|
+
};
|
|
497
|
+
return messageObj;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
exports.Logger = Logger;
|
|
501
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AACjE,yBAAyB;AACzB,6BAA6B;AAC7B,4BAA4B;AAC5B,6BAA6B;AAC7B,6BAA6B;AAC7B,sDAAsD;AAEtD,kDAA+C;AAE/C,MAAM,wBAAwB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,YAAY,CAAC;AAE9E,6CAA6C;AAC7C,yBAAyB;AACzB,6CAA6C;AAC7C,gEAA0D;AAAjD,yGAAA,QAAQ,OAAA;AAEjB,6CAA6C;AAC7C,yCAAyC;AACzC,4CAA4C;AAC5C,8BAA8B;AAC9B,6CAA6C;AAC7C,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;IACpC,WAAW,EAAE,MAAM;CACpB,CAAC,CAAC;AAEH,6CAA6C;AAC7C,YAAY;AACZ,6CAA6C;AAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,qBAAS,CAAC,OAAO,eAAe,CAAC,CAAC;AACjE,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC;AACjC,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC;AAEvC,IAAI,cAA2B,CAAC;AAChC,IAAI,aAA4B,CAAC;AACjC,IAAI,WAAW,GAAY,KAAK,CAAC;AAEjC,uCAAuC;AACvC,MAAM,cAAc,GAAa,EAAE,CAAC;AAEpC,IAAI,WAAgB,CAAC;AAarB;;GAEG;AACU,QAAA,wBAAwB,GAAG,CAAC,YAAwB,EAAU,EAAE;IAC3E,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF;;GAEG;AACU,QAAA,+BAA+B,GAAG,CAAC,QAAkB,EAAc,EAAE;IAChF,IAAI,SAAS,GAAe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S,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;SAChE;QAED,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACnF,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC;QAE/F,UAAU,CAAC,GAAG,GAAG;YACf,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAjUD,wBAiUC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
/**
|
|
3
|
+
* The "--no-timeouts" arg doesn't work to disable
|
|
4
|
+
* the Mocha timeouts (while debugging) if a timeout
|
|
5
|
+
* is specified in the code itself. Using this to set the
|
|
6
|
+
* timeouts does.
|
|
7
|
+
*/
|
|
8
|
+
export declare function timeout(mocha: Mocha.Suite | Mocha.Context, milliSec: number): void;
|