You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

4 weeks ago
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mxlog = void 0;
let log4js = require('log4js');
log4js.configure({
appenders: [
{
type: 'console',
category: "console"
},
{
type: "dateFile",
filename: 'logs/',
pattern: "yyyyMMdd.txt",
alwaysIncludePattern: true,
//category: 'console'
} //�����ļ���ʽ
],
replaceConsole: true,
levels: {
MXINFO: 'info',
MXERROR: 'error',
MXWARN: 'warn',
MXDEBUG: 'debug',
}
});
var log_info = log4js.getLogger('MXINFO');
class Mxlog {
constructor(log4js) {
this.log_info = log4js.getLogger('MXLOG');
this.log_error = log4js.getLogger('MXERROR');
this.log_warn = log4js.getLogger('MXWARN');
this.log_debug = log4js.getLogger('MXDEBUG');
}
error(obj) {
this.log_error.error(obj);
}
warn(obj) {
this.log_warn.warn(obj);
}
info(obj) {
this.log_info.info(obj);
}
debug(obj) {
this.log_debug.debug(obj);
}
use(app) {
//ҳ��������־,��auto�Ļ�,Ĭ�ϼ�����WARN
app.use(log4js.connectLogger(log_info, { level: 'auto', format: ':method :url' }));
//app.use(log4js.connectLogger(log_info, { level: 'debug', format: ':method :url' }));
}
}
exports.Mxlog = Mxlog;
exports.default = new Mxlog(log4js);
//# sourceMappingURL=log.js.map