@forrestjs/service-logger

    4.5.3 • Public • Published

    @forrestjs/service-logger

    ForrestJS service which helps logging stuff in the server. It uses winston under the hood.

    Usage

    service-logger injects a Winston logger instance into the App context, so you will be able to access it from any action:

    registerAction({
      target: '$FINISH',
      handler: (args, ctx) => {
        ctx.logger.info('Test');
      },
    });

    After the Hooks App gets initialized, you can also access some direct logging methods by importing them directly:

    const logger = require('@forrestjs/service-logger');
    logger.logInfo('test...');

    Configuration

    Environment

    NOTE: it is important to list service-logger AFTER service-env so that any kind of environment configuration is available to be used.

    LOG_LEVEL should be set according to the winston docs and it defaults to info.

    Config

    logger.level should be set according to the winston docs and it default to process.env.LOG_LEVEL.

    Provide custom transporters

    In order to add your custom transporters you must register your extension as a service or as a standalone hook before running createHookApp, as Service Logger hooks into START with the purpose of providing the rest of the app with a viable logging mechanism.

    const serviceLogger = require('@forrestjs/service-logger');
    
    registerAction({
      target: '$LOGGER_TRANSPORTS',
      handler: ({ registerTransport, winston }) =>
        registerTransport(new winston.transports.Console()),
    });

    Install

    npm i @forrestjs/service-logger

    DownloadsWeekly Downloads

    328

    Version

    4.5.3

    License

    MIT

    Unpacked Size

    6.63 kB

    Total Files

    5

    Last publish

    Collaborators

    • marcopeg