import logger from '../src/logger' let log = {} class LogTest { constructor(opts) { log = logger({ // pretty: {translateTime:true, colorize:true, levelFirst:true } // options for pino pretty printer // env:'', // 'dev' or 'pro' -- can be use to set/override UCI_ENV environment variable // enForce: false, // only used with .evn. if true will override UCI_ENV if it is set, otherwise no // level:'info', // info is default level, set level to lowest visible // clear: false, // true for log files will clear the current log file on restart // logFileName:'test', // if not supplied log filename will be generated from timestamp // below properties are optional and are passed to child logger instance and will be part of json log entry // libraryName: 'UCI', // will be logged as name: can be used to identify logs of related packages, can be set via UCI_LOG_NAME env variable appName:'uci-example-logger', //will be used for logging directory name if supplied and will be logged as well package: '@uci/logger', // name of package with scope per package.json // repo: // will use scope-name from package prop if not supplied id: opts.id, // can pass a unique if for easy later search/filtering // file: 'example/example.js', // path (to repo root) of actual file running this logger, default is ./src/.js class: 'LogTest', // The class that created this logger if any // one can pass through additional props to log for every log // should not use any keys above or // level,time,msg,pid,hostname // logPath,instanceCreatedHR,instanceCreated as keys will be merged // NOTE: more props can be added at run time by passing an object of props additional: {anotherprop:'test'} // should do not use any keys above or 'level,logPath,package,instanceCreatedHR,instanceCreated' as keys will be merged }) } logit() { log.trace('this is a trace level logged message') log.debug('this is a debug level logged message') log.info({runtimeprop:'somevalue', msg:'this is a info level logged message'}) log.warn('this is a warn level logged message') log.error('this is a error level logged message') log.fatal('this is a fatal level logged message') log.clear('This would clear the log') } } let test = new LogTest({id:'logtest-via-new'}) test.logit()