logger.js
711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
/**
* Sequelize module for debug and deprecation messages.
* It require a `context` for which messages will be printed.
*
* @module logging
* @private
*/
const debug = require('debug');
const util = require('util');
class Logger {
constructor(config) {
this.config = {
context: 'sequelize',
debug: true,
...config
};
}
warn(message) {
// eslint-disable-next-line no-console
console.warn(`(${this.config.context}) Warning: ${message}`);
}
inspect(value) {
return util.inspect(value, false, 3);
}
debugContext(name) {
return debug(`${this.config.context}:${name}`);
}
}
exports.logger = new Logger();
exports.Logger = Logger;