Nested Public Modules

    @playo/logger
    TypeScript icon, indicating that this package has built-in type declarations

    0.9.24 • Public • Published

    Playo-logger

    It will create logs winston according to services

    It will delete logs before 30 days

    PASS SERVER=production to skip debug logs

    Log Levels

    1. alert (Highest Priority)
    2. error
    3. info
    4. debug

    How to use

    1. Basic Logger create one logger file and add

      const PlayoLogger = require("@playo/logger");
      
      const Logger = new PlayoLogger("<service-name>");
      
      module.exports = Logger;

      It will create <service-name>-YYYY-MM-DD-info , <service-name>-YYYY-MM-DD-error, <service-name>-YYYY-MM-DD-debug file in /var/log/playo folder

    2. Store Logs in Different Path

      const PlayoLogger = require("@playo/logger");
      
      const Logger = new PlayoLogger("<service-name>", "<path-name>");
      
      module.exports = Logger;

      It will create <service-name>-YYYY-MM-DD-info , <service-name>-YYYY-MM-DD-error, <service-name>-YYYY-MM-DD-debug file in <path-name> folder

    3. Mail Logger

      const PlayoLogger = require("@playo/logger");
      
      const Logger = new PlayoLogger("<service-name>");
      Logger.setMailer({
        'receiverEmail': ["test@mail.com"], // array of recievers, mandatory
        'senderEmail': "logger@mail.com" // address of sender, mandatory
        'senderName': 'Mail Logger' // default: Mail Logger, optional
        'replyEmail': 'no-reply@mail.com' // default: no-reply@playo.co, optional
        'region': "us-east-1", // default: 'us-east-1', optional
      });
      module.exports = Logger;

      Env Variables

        AWS_ACCESS_KEY_ID
        AWS_SECRET_ACCESS_KEY
    4. Slack Logger

      const PlayoLogger = require("@playo/logger");
      
      const Logger = new PlayoLogger("<service-name>");
      Logger.setSlack("<channel>");
      
      // <channel> is optional, default is 'general'
      
      module.exports = Logger;

      Env Variables

        SLACK_TOKEN
    5. Custom keys

      const PlayoLogger = require("@playo/logger");
      
      const Logger = new PlayoLogger("<service-name>");
      Logger.set(key, value);
      
      module.exports = Logger;

      set can be used in the file which requires the logger instance

    Example with mail and slack Logger

    const PlayoLogger = require("@playo/logger");
    
    const Logger = new PlayoLogger("utils");
    
    Logger.setSlack("server_alerts");
    Logger.setMailer({
      receiverEmail: ["test@mail.com"], // array of recievers, mandatory
      senderEmail: "logger@mail.com" // address of sender, mandatory
    });
    module.exports = Logger;

    Pass Env for mail and slack logger

      AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY
      SLACK_TOKEN

    How to Log

    Logger.debug(id, data, message);
    Logger.info(id, data, message);
    Logger.error(id, data, message);

    On Critical Logs, Put both error and alert log

    Logger.alert(id, data, message);
    Logger.error(id, data, message);

    Keywords

    none

    Install

    npm i @playo/logger

    DownloadsWeekly Downloads

    26

    Version

    0.9.24

    License

    ISC

    Unpacked Size

    14.9 kB

    Total Files

    14

    Last publish

    Collaborators

    • rishabh09
    • umashankar_playo