Socket
Socket
Sign inDemoInstall

logging-chiper

Package Overview
Dependencies
169
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    logging-chiper

just a little module to log


Version published
Weekly downloads
255
decreased by-26.51%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Logging Chiper

Table of Contents

  • Logging Chiper
  • Table of Contents
  • Description
  • Motivation
  • Requirements
  • Usage

Description

This simple module offers a way to use some functionalities from the logging-chiper.

Motivation

As company we want to standardize the way we log our application, so that's we wrote this module to make it easier to log our application.

Requirements

  1. Nodejs LTS.
  2. GOOGLE_APPLICATION_CREDENTIALS defined with the file path as environment variable.

Usage

Install

npm i logging-chiper -S -E

OR

yarn add logging-chiper -S -E

Parameters

As we want to standardize the way we log our application, so we defined a base structure as input parameters to accomplish this:

// Log method
Logger.log({
  stt: "my-stt", // name of the stt owner
  context: "my-context", // name of the class or file (optional)
  functionName: "my-function", // name of the function (optional)
  message: "my-message", // message to log
  data: { // data to log (optional)
    storeId: "" + 123456,
    responseCode: "" + 200,
    testField: "test",
    extraField: "extra",
  },
});

// Warn method
Logger.warn({
  stt: "my-stt", // name of the stt owner
  context: "my-context", // name of the class or file (optional)
  functionName: "my-function", // name of the function (optional)
  message: "my-message", // message to log
  data: { // data to log (optional)
    storeId: "" + 123456,
    responseCode: "" + 200,
    testField: "test",
    extraField: "extra",
  },
});

// Error method
Logger.warn({
  stt: "my-stt", // name of the stt owner
  context: "my-context", // name of the class or file (optional)
  functionName: "my-function", // name of the function (optional)
  message: "my-message", // message to log
  error, // the exception to log that just occurred
  data: { // data to log (optional)
    storeId: "" + 123456,
    responseCode: "" + 200,
    testField: "test",
    extraField: "extra",
  },
});

As you can see, all the methods follows almost the same structure, but when you want to log an error, you need to pass the error as parameter.

Example

import { Logger } from 'logging-chiper';

const bootstrap = () => {
  Logger.log({
    stt: 'solutions',
    context: 'main.ts',
    functionName: 'bootstrap',
    message: 'this is a log message...',
  });
};
}

bootstrap();

FAQs

Last updated on 03 Mar 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc