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