mirror of
https://github.com/franjsco/tick3t-api
synced 2024-12-22 04:56:36 +01:00
add logger
This commit is contained in:
parent
ef9fb12a99
commit
4f85873d1f
29
src/logger.js
Normal file
29
src/logger.js
Normal file
@ -0,0 +1,29 @@
|
||||
import winston from 'winston';
|
||||
|
||||
const { format } = winston;
|
||||
|
||||
|
||||
const customFormat = format.printf(({
|
||||
level,
|
||||
message,
|
||||
label,
|
||||
timestamp,
|
||||
}) => `${timestamp} [${label}] ${level}: ${message}`);
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: 'info',
|
||||
format: format.combine(
|
||||
format.label({ label: 'tick3t-api' }),
|
||||
format.timestamp(),
|
||||
customFormat,
|
||||
),
|
||||
defaultMeta: { service: 'user-service' },
|
||||
transports: [
|
||||
new winston.transports.File({ filename: 'error.log', level: 'error' }),
|
||||
new winston.transports.File({ filename: 'combined.log' }),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
|
||||
export default logger;
|
Loading…
Reference in New Issue
Block a user