summaryrefslogtreecommitdiffstats
path: root/cds-ui/server/src/logger/logger.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/server/src/logger/logger.ts')
-rw-r--r--cds-ui/server/src/logger/logger.ts25
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