1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/glogg/index.js

35 lines
541 B
JavaScript
Raw Normal View History

2023-12-18 13:12:25 +08:00
'use strict';
var format = require('util').format;
var sparkles = require('sparkles');
var levels = [
'debug',
'info',
'warn',
'error',
];
function getLogger(namespace) {
var logger = sparkles(namespace);
levels.forEach(function(level) {
logger[level] = makeLogLevel(logger, level);
});
return logger;
}
function makeLogLevel(self, level) {
return function(msg) {
if (typeof msg === 'string') {
msg = format.apply(null, arguments);
}
self.emit(level, msg);
};
}
module.exports = getLogger;