npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fengcart/logger

v1.17.0

Published

Common logging utilities

Downloads

30

Readme

@fengcart/logger

New Shared logging library for CTG

Installation

yarn add @fengcart/logger

Usage

The default logger will cover almost all use cases.

import log from '@fengcart/logger';

function hello() {
  log.info({ data: 'Some data' }, 'A log message');
}

Output

2018-12-20T17:05:25.330Z  INFO  A log message
{
   "level": 30,
   "message": "Some A log message",
   "data": "Some data"
}

Lambda Functions

For usage in a Lambda function, you can capture request information which will append the request and tracing IDs to all log statements. This functionality is provided by pino-lamdba.

See the default tags that are tracked in Lambda functions.

The usage of withRequest is global, that is, you do not need to pass instances of logger around to other classes or functions. Calling withRequest once will track tags in ALL logger instances across the application, regardless of the method you use to import or create the logger.

import log from '@fengcart/logger';

export async function handler(event, context) {
  log.withRequest(event, context);

  log.info({ data: 'Some data' }, 'A log message');
}

Output

2018-12-20T17:05:25.330Z    6fccb00e-0479-11e9-af91-d7ab5c8fe19e    INFO  A log message
{
   "awsRequestId": "6fccb00e-0479-11e9-af91-d7ab5c8fe19e",
   "x-correlation-id": "238da608-0542-11e9-8eb2-f2801f1b9fd1",
   "x-correlation-trace-id": "Root=1-5c1bcbd2-9cce3b07143efd5bea1224f2;Parent=07adc05e4e92bf13;Sampled=1",
   "level": 30,
   "message": "Some A log message",
   "data": "Some data"
}

Default Tags

By default, the following tags are tracked in all log messages

| Property | Value | Info | | ------------------------- | ------------------------------------------ | ------------------------------------------------------------------------ | | awsRequestId | context.awsRequestId | The unique request id for this request | | x-correlation-id | event.headers['x-correlation-id'] | The upstream request id for tracing | | x-correlation-trace-debug | event.headers['x-correlation-debug'] | The upstream service wants debug logs enabled for this request | | x-correlation-trace-id | process.env.X_AMZN_TRACE_ID | The AWS tracing id | | x-correlation-* | event.headers.startsWith('x-correlation-') | Any header that starts with x-correlation- will be automatically added | | name | process.env.AWS_LAMBDA_FUNCTION_NAME | The lambda function name | | stage | process.env.STAGE or process.env.NODE_ENV | Application Stage | | brand | process.env.BRAND | RBI Brand | | region | process.env.REGION | RBI Region/Country Code |

These tags are compatible with what Datadog expects and AWS specific metrics will be ignored in non-aws environments.

Configuration

Log level output is controlled by environment variables set to fatal, error, warn, info (default), debug, trace, or silent

LOG_LEVEL=debug

Log level can also be controlled by upstream requests. If an incoming request contains a header of x-correlation-debug set to true, the logger will be set to debug level for that request.

In rare cases where the logger needs to be customized further, we will support all options that the underlying logging provider itself supports for configuration (by default pino).

Local Development

Local development provides a more readable output using pino-pretty by setting the LOG_PRETTY environment variable to true;

demo

Child Loggers

You can create named child loggers which will output to add an additional tags to all messages.

import logger from '@fengcart/logger';

const childLogger = logger.child({
  module: 'Foo',
  // any additional tags
});

childLogger.info({ data: 'Some data' }, 'A log message');

Output

2018-12-20T17:05:25.330Z    6fccb00e-0479-11e9-af91-d7ab5c8fe19e    INFO  A log message
{
   "awsRequestId": "6fccb00e-0479-11e9-af91-d7ab5c8fe19e",
   "x-correlation-id": "238da608-0542-11e9-8eb2-f2801f1b9fd1",
   "x-correlation-trace-id": "Root=1-5c1bcbd2-9cce3b07143efd5bea1224f2;Parent=07adc05e4e92bf13;Sampled=1",
   "level": 30,
   "message": "Some A log message",
   "data": "Some data",
   "module": "Foo"
}

Custom Loggers

// logger.ts
import { create } from '@fengcart/logger';
export default create({
  // any pino options
});
// handler.ts
import log from './logger';

export async function handler(event, context) {
  log.withRequest(event, context);

  log.info({ data: 'Some data' }, 'A log message');
}

NestJS

The ApiLogger class implements a simple NestJS LoggerService that logs with the RBI logger instance.

import { ApiLogger } from '@fengcart/logger';

const app = await NestFactory.create(AppModule, { logger: new ApiLogger() });