UNPKG

1.53 kBJavaScriptView Raw
1"use strict";
2const winston = require('winston');
3function getLogger() {
4 return new (winston.Logger)({
5 transports: [
6 new (winston.transports.Console)()
7 ]
8 });
9}
10/**
11 * A wrapper around the winston logging framework.
12 */
13class 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 * Logs the message as info.
27 * @param message The message to be logged.
28 * @param meta Any additional metadata.
29 */
30 logInfo(message, meta) {
31 this.winstonLogger.log('info', message, meta);
32 }
33 /**
34 * Logs the message as Debug
35 * @param message The message to be logged
36 * @param meta Any additional metadata
37 */
38 logDebug(message, meta) {
39 this.winstonLogger.log('debug', message, meta);
40 }
41 /**
42 * Logs the message as Erro
43 * @param message The message to be logged
44 * @param meta Any additional metadata
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}
56var winstonLog = new WinstonLog();
57exports.winstonLog = winstonLog;
58
59//# sourceMappingURL=winstonLog.js.map