codimd/lib/logger.ts
Raccoon 6696a0ab74
ts: lib/config/index.js
Signed-off-by: Raccoon <raccoon@hackmd.io>
2021-06-16 18:35:26 +08:00

36 lines
683 B
TypeScript

import {createLogger, format, transports, Logger} from "winston";
type CodiMDLogger = Logger & {
stream: any
setLevel?: (string) => void
}
let logger: CodiMDLogger = createLogger({
level: 'debug',
format: format.combine(
format.uncolorize(),
format.timestamp(),
format.align(),
format.splat(),
format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
),
transports: [
new transports.Console({
handleExceptions: true
})
],
exitOnError: false
})
logger.stream = {
write: function (message, encoding) {
logger.info(message)
}
}
logger.setLevel = function (level) {
logger.level = level
}
export = logger