@@ -2,7 +2,7 @@ import os from 'os';
22import * as winston from 'winston' ;
33import DailyRotateFile from 'winston-daily-rotate-file' ;
44import { Syslog } from 'winston-syslog' ;
5- import { LogToEvTransport } from './custom_transport' ;
5+ import { LogToEvTransport , NoOpTransport } from './custom_transport' ;
66const { combine, timestamp } = winston . format ;
77import traverse from "traverse" ;
88import { klona } from "klona/full" ;
@@ -55,6 +55,11 @@ function truncate(str: string, n: number) {
5555
5656const formatRedact = winston . format ( redact ) ;
5757
58+ /**
59+ * To prevent "Attempt to write logs with no transports" error
60+ */
61+ const placeholderTransport = new NoOpTransport ( )
62+
5863const makeLogger = ( ) =>
5964 winston . createLogger ( {
6065 format : combine (
@@ -65,10 +70,17 @@ const makeLogger = () =>
6570 winston . format . simple ( )
6671 ) ,
6772 levels : winston . config . syslog . levels ,
68- } ) ;
73+ transports : [ placeholderTransport ]
74+ } ) ;
6975
76+ /**
77+ * You can access the log in your code and add your own custom transports
78+ */
7079export const log = makeLogger ( ) ;
7180
81+ if ( log . warning && ! log . warn ) log . warn = log . warning
82+ if ( log . alert && ! log . help ) log . help = log . alert
83+
7284export const addRotateFileLogTransport = ( options : any = { } ) => {
7385 log . add (
7486 new DailyRotateFile ( {
0 commit comments