1 | "use strict";
|
2 | const winston = require('winston');
|
3 | function getLogger() {
|
4 | return new (winston.Logger)({
|
5 | transports: [
|
6 | new (winston.transports.Console)()
|
7 | ]
|
8 | });
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 | class WinstonLog {
|
14 | constructor() {
|
15 | this.winstonLogger = null;
|
16 | this.logStream = null;
|
17 | this.winstonLogger = getLogger();
|
18 | var _logger = this.winstonLogger;
|
19 | this.logStream = {
|
20 | write: function (message, encoding) {
|
21 | _logger.debug(message);
|
22 | }
|
23 | };
|
24 | }
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 | logInfo(message, meta) {
|
31 | this.winstonLogger.log('info', message, meta);
|
32 | }
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 | logDebug(message, meta) {
|
39 | this.winstonLogger.log('debug', message, meta);
|
40 | }
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | logError(message, meta) {
|
47 | this.winstonLogger.log('error', message, meta);
|
48 | }
|
49 | configure(options) {
|
50 | this.winstonLogger.configure(options);
|
51 | }
|
52 | getStream() {
|
53 | return this.logStream;
|
54 | }
|
55 | }
|
56 | var winstonLog = new WinstonLog();
|
57 | exports.winstonLog = winstonLog;
|
58 |
|
59 |
|