diff options
author | Rami <rmohamed.ext@orange.com> | 2019-05-27 17:23:37 +0200 |
---|---|---|
committer | Rami <rmohamed.ext@orange.com> | 2019-05-30 11:39:54 +0200 |
commit | 174110278bd235b7bf878fc4bd773078d633ce00 (patch) | |
tree | 89d2931a0455f5d9f689f6120798e620a0df2713 /cds-ui/server/src/logger | |
parent | 1f69e1c3569196305c23f085cfbc03bdba14f4e0 (diff) |
Add logger to the server
- add logger with interceptor for requests
Change-Id: Iecb6b6e51c28aadcc4eec3bb69dc38f4e0e346c5
Issue-ID: CCSDK-1295
Signed-off-by: Rami <rmohamed.ext@orange.com>
Diffstat (limited to 'cds-ui/server/src/logger')
-rw-r--r-- | cds-ui/server/src/logger/logger.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cds-ui/server/src/logger/logger.ts b/cds-ui/server/src/logger/logger.ts new file mode 100644 index 000000000..6acbd396f --- /dev/null +++ b/cds-ui/server/src/logger/logger.ts @@ -0,0 +1,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 };
\ No newline at end of file |