neura-express-app
Version:
Basic express application starter with some common utilities.
47 lines (46 loc) • 1.37 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BunyanLogger = void 0;
const bunyan_1 = __importDefault(require("bunyan"));
const bunyan_format_1 = __importDefault(require("bunyan-format"));
/**
* Wrapper class for Bunyan logger.
*/
class BunyanLogger {
constructor(config) {
this.config = config;
if (!config.enabled) {
return;
}
const stream = config.prettyPrint
? new bunyan_format_1.default({
color: true,
outputMode: "long",
})
: process.stdout;
this.underlyingLogger = bunyan_1.default.createLogger({
name: config.appName,
level: config.level,
stream,
});
}
verbos(msg, ...args) {
this.underlyingLogger?.debug(msg, ...args);
}
debug(msg, ...args) {
this.underlyingLogger?.debug(msg, ...args);
}
info(msg, ...args) {
this.underlyingLogger?.info(msg, ...args);
}
warn(msg, ...args) {
this.underlyingLogger?.warn(msg, ...args);
}
error(msg, ...args) {
this.underlyingLogger?.error(msg, ...args);
}
}
exports.BunyanLogger = BunyanLogger;