kucherenko / ol0lo

0 stars 0 forks source link

Implement task #35 - Smart Logger with different transports #38

Closed brian-ai-assistant-dev[bot] closed 1 year ago

brian-ai-assistant-dev[bot] commented 1 year ago

To implement the Smart Logger with different transports, I would suggest creating a new file called SmartLogger.js within the utils folder. This file will contain the logic for logging messages with different transports.

Here is a possible implementation for the SmartLogger.js file:

class SmartLogger {
  constructor() {
    this.transports = [];
  }

  addTransport(transport) {
    this.transports.push(transport);
  }

  log(message) {
    this.transports.forEach((transport) => {
      transport.send(message);
    });
  }
}

module.exports = SmartLogger;

This implementation defines a SmartLogger class with a constructor that initializes an empty array of transports. The addTransport method is used to add different transports to the logger. The log method iterates over the transports array and calls the send method on each transport, passing the message as an argument.

To use the SmartLogger, you can create an instance of it and add different transports to it. For example:

const logger = new SmartLogger();

logger.addTransport(new ConsoleTransport());
logger.addTransport(new FileTransport('path/to/logfile.txt'));
logger.addTransport(new EmailTransport('admin@example.com'));

logger.log('Hello, world!');

In this example, we create an instance of SmartLogger and add three different transports: ConsoleTransport, FileTransport, and EmailTransport. The log method is then called to log a message, which will be sent to all the added transports.

For the commit message, I suggest using 'Implement SmartLogger with different transports'.

netlify[bot] commented 1 year ago

Deploy Preview for willowy-kleicha-1542e1 ready!

Name Link
Latest commit a89b1d2cd0efdf8857026261a8d62e7487f5e6cb
Latest deploy log https://app.netlify.com/sites/willowy-kleicha-1542e1/deploys/64afdc9599b0020008a42b50
Deploy Preview https://deploy-preview-38--willowy-kleicha-1542e1.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.