badman-core
Version:
badman-core is the layer what all the badman packages depended,or can be used as a tool kit.
50 lines • 1.78 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const log4js_1 = __importDefault(require("log4js"));
/**
* 日志组件
*/
class Logging {
constructor(customLog4jOptions) {
this.defaultConfiguration = {
"appenders": {
"stdout_appender": {
"type": "stdout",
"layout": { "type": "pattern", "pattern": "%[[CDPID(%z)]-[%d{yyyy-MM-dd hh:mm:ss.SSS} %c-%p] [%f{1}<%A>.%M(%l)] %] <=> %m %n" }
}
},
"categories": {
"default": {
"appenders": ["stdout_appender"],
"level": "info",
"enableCallStack": true
}
}
};
this.customLog4jOptions = customLog4jOptions;
}
afterInitialized() {
if (!this.log4jsInstance) {
if (this.customLog4jOptions) {
this.log4jsInstance = log4js_1.default.configure(this.customLog4jOptions);
this.log4js().getLogger().info(` Log4js configuration state is ${this.log4jsInstance.isConfigured()}`);
}
else {
this.log4jsInstance = log4js_1.default.configure(this.defaultConfiguration);
this.log4js().getLogger().info(`Default Log4js configuration state is ${this.log4jsInstance.isConfigured()}`);
}
}
return;
}
log4js() {
return this.log4jsInstance;
}
logger(category) {
return this.log4js().getLogger(category);
}
}
exports.default = Logging;
//# sourceMappingURL=Logging.js.map