Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
176 additions
and
15 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
import * as winston from 'winston'; | ||
import { LoggerFunction } from './Environment'; | ||
|
||
const testLogger: LoggerFunction = (namespace, level, ...msg) => { | ||
require('debug')(namespace)(...msg); | ||
const { combine, timestamp, printf } = winston.format; | ||
|
||
const myFormat = printf(info => { | ||
return `${info.timestamp} ${info.level} ${info.message}`; | ||
}); | ||
|
||
const logger = winston.createLogger({ | ||
format: combine(timestamp(), myFormat), | ||
level: 'debug', | ||
transports: [ | ||
new winston.transports.File({ | ||
filename: `./logs/${new Date().toISOString()}.log`, | ||
}), | ||
], | ||
}); | ||
|
||
logger.debug(['melon:protocol:logger', 'init', ...process.argv].join(' ')); | ||
|
||
const testLogger: LoggerFunction = (namespace, level, ...msgs) => { | ||
const message = [ | ||
`${namespace}:`, | ||
...msgs.map(msg => JSON.stringify(msg, null, 2)), | ||
].join(' '); | ||
logger.log(level, message); | ||
require('debug')(namespace)(level, ...msgs); | ||
}; | ||
|
||
export { testLogger }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters