Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: DEFAULT_LOGGER_NAME,
streams: [{
type: 'raw',
name: 'ConsoleLogStream',
stream: new ConsoleLogStream({formatter: LogFormatter}),
level: 'info'
}],
level: 'info'
};
this.rootLogger = new Logger(rootLoggerOptions);
this._bindNodeLoggerMethods(this.rootLogger);
this._cleanLoggersInterval = null;
this.nameFromLevel = bunyan.nameFromLevel;
this.levelFromName = bunyan.levelFromName;
this.DEFAULT_LOGGER_NAME = DEFAULT_LOGGER_NAME;
// in case the node we're running has it's own logging system, we'll
// allow users to pass in callbacks for getting and setting loggers
// through the logging services (_handleGetLoggers, _handleSetLoggerLevel)
this._externalLog = {
getLoggers: null,
setLoggerLevel: null
};
KNOWN_LOGS.forEach((log) => {
this.generateLogger(log);
});
}
'use strict';
const bunyan = require('bunyan');
const Hoek = require('hoek');
const Joi = require('joi');
/**
* @constant {array} availableLevels - List of available Bunyan log levels
* @private
*/
const availableLevels = Object.keys(bunyan.levelFromName);
/**
* @constant {object} schema - Validation schema
* @private
*/
const schema = {
levels: {
ops: Joi.string().valid(availableLevels),
response: Joi.string().valid(availableLevels),
error: Joi.string().valid(availableLevels),
log: Joi.string().valid(availableLevels),
request: Joi.string().valid(availableLevels)
},
logger: Joi.object().required(),
formatters: Joi.object()
};
constructor () {
Object.keys(bunyan.levelFromName).forEach((level) => {
this[level] = function () {
process.send({type: 'log', level, arguments: Array.from(arguments)})
}
this[`sys${level.charAt(0).toUpperCase()}${level.slice(1)}`] = function () {
process.send({type: 'systemLog', level, arguments: Array.from(arguments)})
}
})
}
}