Skip to content

Commit b16fbb8

Browse files
winston:add winston logger support
1 parent 298fe2f commit b16fbb8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/util/logger.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import winston from 'winston';
2+
3+
const options: winston.LoggerOptions = {
4+
transports: [
5+
new winston.transports.Console({
6+
level: process.env.NODE_ENV === 'production' ? 'error' : 'debug'
7+
}),
8+
new winston.transports.File({ filename: 'debug.log', level: 'debug' })
9+
]
10+
};
11+
12+
const logger = winston.createLogger(options);
13+
14+
if (process.env.NODE_ENV !== 'production') {
15+
logger.debug('Logging initialized at debug level');
16+
}
17+
18+
export default logger;

0 commit comments

Comments
 (0)