5 Star 35 Fork 13

nygula / Node-Media-Server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
node_core_logger.js 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
illuspas 提交于 2018-06-20 11:35 . Implement the multicore cluster mode.
const chalk = require('chalk');
LOG_TYPES = {
NONE: 0,
ERROR: 1,
NORMAL: 2,
DEBUG: 3,
FFDEBUG: 4
};
let logType = LOG_TYPES.NORMAL;
const setLogType = (type) => {
if (typeof type !== 'number') return;
logType = type;
};
const logTime = () => {
let nowDate = new Date();
return nowDate.toLocaleDateString() + ' ' + nowDate.toLocaleTimeString([], { hour12: false });
};
const log = (...args) => {
if (logType < LOG_TYPES.NORMAL) return;
console.log(logTime(), process.pid, chalk.bold.green('[INFO]'), ...args);
};
const error = (...args) => {
if (logType < LOG_TYPES.ERROR) return;
console.log(logTime(), process.pid, chalk.bold.red('[ERROR]'), ...args);
};
const debug = (...args) => {
if (logType < LOG_TYPES.DEBUG) return;
console.log(logTime(), process.pid, chalk.bold.blue('[DEBUG]'), ...args);
};
const ffdebug = (...args) => {
if (logType < LOG_TYPES.FFDEBUG) return;
console.log(logTime(), process.pid, chalk.bold.blue('[FFDEBUG]'), ...args);
};
module.exports = {
LOG_TYPES,
setLogType,
log, error, debug, ffdebug
}
1
https://gitee.com/nygula/Node-Media-Server.git
git@gitee.com:nygula/Node-Media-Server.git
nygula
Node-Media-Server
Node-Media-Server
master

搜索帮助