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

logs-datalake

v0.1.6

Published

DTVGO Nodejs log lib

Readme

CustomLogger

CustomLogger is a lightweight logging library for Node.js that allows you to incrementally add log information and generate custom log outputs. It provides a fluent API for building log data and supports various log components such as configuration values, feature flags, request and response data, third-party service interactions, user data, and custom information.

Installation

Install the library using npm:

npm install @dtvgo-be/pkg-dtvgo-log

Usage

Importing the Library

To use CustomLogger, import it into your Node.js application:

const CustomLogger = require('@dtvgo-be/pkg-dtvgo-log');

Creating an Instance

Create a new instance of CustomLogger:

const logger = new CustomLogger();

Using custom fields to remove sensitive information

const logger = new CustomLogger(['documentID', 'cpf', 'tokenX']);

This way you could remove sensitive information no mapped by default on lib in all functions that using logs, configuration, request and responses

Adding Log Data

Adding Configuration Values

Use the addConfig method to add configuration values to the log data:

logger.addConfig({
  environment: 'production',
  serverPort: 8080,
});

or

logger.addConfig({ environment: 'production' });
logger.addConfig({ serverPort: 8080 });

The resulting config data object will contain all the expected properties:

{
  "environment": "production",
  "serverPort": 8080
}

Adding Feature Flags

Add feature flags to the log data using the addFeatureFlags method:

logger.addFeatureFlags({
  enableFeatureA: true,
  enableFeatureB: false,
});

or

logger.addFeatureFlags({ enableFeatureA: true });
logger.addFeatureFlags({ enableFeatureB: false });

The resulting Feature Flags data object will contain all the expected properties:

{
  "enableFeatureA": true,
  "enableFeatureB": false
}

Adding Request and Response Data

Include request and response data using the addRequest and addResponse methods:

logger.addRequest({
  method: 'GET',
  path: '/api/users',
});

logger.addResponse({
  statusCode: 200,
  body: { message: 'Success' },
});

Adding Third-Party Service Interactions

For third-party service interactions, use the addThirdPartyRequest and addThirdPartyResponse methods:

logger.addThirdPartyRequest('analytics', {
  method: 'POST',
  url: 'https://api.analytics.com/event',
  data: { eventName: 'Login', userId: '123' },
});

logger.addThirdPartyResponse('analytics', {
  statusCode: 200,
  body: { success: true },
});

Adding User Data

To include user data, use the addUser method:

logger.addUser({ userId: 123 });
logger.addUser({ deviceType: 'mobile', deviceVersion: '1.0' });
logger.addUser({ userToken: 'abc123' });

or

logger.addUser({
  userId: 123,
  deviceType: 'mobile',
  deviceVersion: '1.0',
  userToken: 'abc123'
});

The resulting user data object will contain all the expected properties:

{
  "userId": 123,
  "deviceType": "mobile",
  "deviceVersion": "1.0",
  "userToken": "abc123"
}

Adding Custom Information

Include custom information using the addCustomInfo method:

logger.addCustomInfo({
  additionalInfo: 'Lorem ipsum dolor sit amet',
  timestamp: new Date(),
});

Adding service error

Include custom information using the addCustomInfo method:

logger.addInternalError(new Error('Internal server error'));

Finishing and Logging

To finish building the log data and generate the log output, call the finish method:

logger.finish();

The log output will be displayed in the console as a formatted JSON string.

Complete Example

Here's a complete example demonstrating how to use CustomLogger with different log components:

const CustomLogger = require('custom-logger');

const logger = new CustomLogger();

logger
  .addConfig({ environment: 'production', serverPort: 8080 })
  .addFeatureFlags({ enableFeatureA: true, enableFeatureB: false })
  .addRequest({ method: 'GET', path: '/api/users' })
  .addResponse({ statusCode: 200, body: { message: 'Success' } })
  .addThirdPartyRequest('analytics', {
    method: 'POST',
    url: 'https://api.analytics.com/event',
    data: { eventName: 'Login', userId: '123' },
  })
  .addThirdPartyResponse('analytics', {
    statusCode: 200,
    body: { success: true },
  })
  .addUser({
    userId: '123',
    userIp: '192.168.0.1',
    deviceType: 'mobile',
    deviceVersion: '1.0.0',
    userToken: 'abc123',
  })
  .addCustomInfo({
    additionalInfo: 'Lorem ipsum dolor sit amet',
    timestamp: new Date(),
  })
  .finish();

The above code will output the formatted log data in the console.

License

This project is licensed under the MIT License - see the LICENSE file for details.