Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mkdir(dir, 0755, function(err){
if (err) throw err;
// master log
var stream = fs.createWriteStream(dir + '/master.log', { flags: 'a' });
var log = master.log = new Log(level || Log.INFO, stream);
// master events
master.on('start', function(){
log.info('master started');
});
// master is shutting down
master.on('closing', function(){
log.warning('shutting down master');
});
// master has closed and performed cleanup
master.on('close', function(){
log.info('shutdown complete');
});
var Log = require('log'),
colors = require('colors');
// Duck Punch the logger
// "... if it walks like a duck and talks like a duck, it's a duck, right? So if
// this duck is not giving you the noise that you want, you've got to just
// punch that duck until it returns what you expect."
Log.SUCCESS = Log.INFO;
Log.prototype.success = function () {
arguments[0] = ' ✔ '.green + arguments[0];
this.log('SUCCESS', arguments);
};
Log.prototype.info = function () {
arguments[0] = ' ➔ '.black + arguments[0];
this.log('INFO', arguments);
};
Log.prototype.error = function () {
arguments[0] = ' ✘ '.red + arguments[0];
this.log('ERROR', arguments);
throw new Error(arguments[arguments.length - 1]);
};
var yaml = require('js-yaml') // register .yaml require handler
, fs = require('fs')
, Log = require('log')
, log = new Log(Log.INFO);
var extend = function(dest, from) {
var props = Object.getOwnPropertyNames(from);
props.forEach(function(name) {
if (name in dest && typeof dest[name] === 'object') {
extend(dest[name], from[name]);
}
else {
var destination = Object.getOwnPropertyDescriptor(from, name);
Object.defineProperty(dest, name, destination);
}
});
};
/**
* Removes properties of the 'dest' object where the 'from' objects
it('should not use time and timeEnd when the level is higher than DEBUG', () => {
log.level = Log.INFO
log.time('test')
log.timeEnd('test')
expect(consoleSpy.time).not.toHaveBeenCalled()
expect(consoleSpy.timeEnd).not.toHaveBeenCalled()
})
}
}
log.timeEnd = function (label) {
if (this.level >= Log.DEBUG) {
console.timeEnd(label)
}
}
log.EMERGENCY = Log.EMERGENCY
log.ALERT = Log.ALERT
log.CRITICAL = Log.CRITICAL
log.ERROR = Log.ERROR
log.WARNING = Log.WARNING
log.NOTICE = Log.NOTICE
log.INFO = Log.INFO
log.DEBUG = Log.DEBUG
module.exports = log