迁移到Winston 3并扩展Winston Logger
我想将Winston Logger扩展到我的自定义记录仪。 在调用内部方法之前,我在哪里更新日志方法。
对于温斯顿2.4.x版 我这样做了。
var winston = require("winston");
var Logger = function(options){
Logger.super_.apply(this, arguments);
}
util.inherits(Logger, winston.Logger);
Logger.prototype.log = function () {
//some logic
Logger.super_.prototype.log.apply(this, args);
};
Now, I am migrating to the Winston version 3.xx
I migrated the above code as
class Logger extends winston.createLogger {
constructor(options) {
super(options);
}
log() {
//some logic
super.log(args);
};
}
The above code is able to create an instance of the logger and start logging the logs but it is not calling my log method instead it's only calling the inbuild Winston日志方法。
I want to extend the Winston logger to my custom logger.
Where I updated the log method before calling the internal method.
For Winston version 2.4.x
I did this.
var winston = require("winston");
var Logger = function(options){
Logger.super_.apply(this, arguments);
}
util.inherits(Logger, winston.Logger);
Logger.prototype.log = function () {
//some logic
Logger.super_.prototype.log.apply(this, args);
};
Now, I am migrating to the Winston version 3.x.x
I migrated the above code as
class Logger extends winston.createLogger {
constructor(options) {
super(options);
}
log() {
//some logic
super.log(args);
};
}
The above code is able to create an instance of the logger and start logging the logs but it is not calling my log method instead it's only calling the inbuild Winston log method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论