aozhiwei 35fa87b5ee 1
2022-04-16 10:47:30 +08:00

42 lines
677 B
JavaScript

const utils = require('./utils');
function warning(msg) {
internalLog('[WARNING]', msg);
}
function info(msg) {
internalLog('[INFO]', msg);
}
function error(msg) {
internalLog('[ERROR]', msg);
}
function alert(msg) {
internalLog('[ALERT]', msg);
}
function debug(msg) {
if (!utils.isOnlineEnv()) {
internalLog('[DEBUG]', msg);
}
}
function internalLog(logClass, msg) {
try {
console.log(utils.formatDate(new Date()) + ' ' + logClass + ' ' + msg);
} catch(err) {
try {
console.log(err);
} catch(err2) {
}
}
}
exports.warning = warning;
exports.info = info;
exports.alert = alert;
exports.error = error;
exports.debug = debug;