New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

genie-logger

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genie-logger

Reusable Node.js logger for platform Lambda services.

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Genie logger Library for Node.js services

Reusable Node.js logger for platform Lambda services.

Installing

To install this library into your project

$ npm i @genie-solutions/genie-logger

Dependencies

This library is built using uuid, winston and winston-transport

Basic Examples

    import { createLoggerFromContext } from "./services/logging";
  
    const createLogger = createLoggerFromContext(APP_NAME, STAGE, LOG_LEVEL);

    const logger = createLogger(context.awsRequestId);

    logger.info({
      type: EventType.CreditAssessed,
      payload: {
        threadId,
        tenantId,
        creditBalance,
        calculatedCost: cost
      }
    });

    logger.error({
      type: EventType.CreditServiceError,
      error: { message: error.message }
    });

    logger.warn({
      type: EventType.CreditServiceWarning,
      error: { message: error.message }
    });
    logger.debug({
      type: EventType.CreditServiceDebug,
      error: { message: error.message }
    });

Profiling Examples

    //
    // Start profile of 'test'
    //
    logger.profile('test');
    
    setTimeout(function () {
      //
      // Stop profile of 'test'. Logging will now take place:
      //   '17 Jan 21:00:00 - info: test duration=1000ms'
      //
      logger.profile('test');
    }, 1000);

This will output {"level":"info","durationMs":2311,"message":"test"} in the log

Profiling Timer example

     // Returns an object corresponding to a specific timing. When done
     // is called the timer will finish and log the duration. e.g.:
     //
     const profiler = logger.startTimer();
     setTimeout(function () {
       profiler.done({ message: 'Logging message' });
     },

This will output {"message":"Logging message","level":"info","durationMs":14990} in the log

Extra metadata inthe log

The default logger will include the three parameter metadata(APP_NAME, STAGE, LOG_LEVEL) in the log, to extend this with extra metadata, use the extend function

  const logger = createLogger(context.awsRequestId).extend(
    pick({ requestId: "451" })
  );

  logger.info("Child logging");

This will output following log:

{"requestId":"451","message":"Child logging","level":"info"}

Keywords

FAQs

Package last updated on 12 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc