Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

104
Views
Migrate to winston 3 and Extend winston logger

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.

7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.