aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/server/src/logger/logger.ts
blob: 6acbd396f236b9270c0a05fa5e20aaad51f8f72b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { createLogger, format, transports } from 'winston';

const { combine, timestamp, printf, splat, errors, colorize } = format;
const logFormat = printf(({ level, message, timestamp }) => {
    return `${timestamp} ${level} ${message}`
});
const logger = createLogger({
    level: 'info',
    format: combine(
        splat(),
        timestamp(),
        colorize(),
        errors({ stack: true }),
        logFormat
    ),
    transports: [
        new transports.Console()
    ]
});

if (process.env.NODE_ENV === 'production') {
    logger.add(new transports.File({ filename: '/var/log/ONAP/CDS-UI/server/server.log'}))
}

export { logger };