filo_caspar/api/log.mjs

21 lines
575 B
JavaScript
Raw Normal View History

2020-04-07 10:36:11 +00:00
import bunyan from 'bunyan-lite'
import defaults from './defaults.mjs'
import config from './config.mjs'
2016-04-10 08:37:05 +00:00
// Clone the settings as we will be touching
// on them slightly.
let settings = defaults(config.get('bunyan'), null)
2016-04-10 08:37:05 +00:00
// Replace any instance of 'process.stdout' with the
// actual reference to the process.stdout.
for (let i = 0; i < settings.streams.length; i++) {
if (settings.streams[i].stream === 'process.stdout') {
settings.streams[i].stream = process.stdout
}
}
// Create our logger.
const logger = bunyan.createLogger(settings)
export default logger