New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

easy-node-logging

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-node-logging

Easily write styled logs to consoles, files, HTTP log aggregation, and more

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

easy-node-logging

A simple solution to logging in Node. Meant to ease debugging of deployments of various scales.

Usage

  • Install the package npm i easy-node-logging
  • Import the module in your project
import { createLoggerFactory } from "easy-node-logging";
  • Set up your loggers and targets
const factory = await createLoggerFactory([
    { type: "STDOUT", color: true },
    { type: "FILE", path: `~/application/logs/all.log`, style: "JSON" },
    { type: "FILE", path: `~/application/logs/error.log`, style: "JSON" level: "ERROR" }
]);
const loggerNetwork = factory.createLogger("NETWORK");
const loggerUsers = factory.createLogger("USERS");
  • Log easily, comfortably, and safe
loggerNetwork.info("New connection:", remote);
loggerUsers.error("Couldn't authenticate user:", username, authReason);
loggerNetwork.warn("Connection closed:", remote, disconnectReason);
// in STDOUT
// [17:42:55.642] [INFO] [NETWORK] New connection: 85.184.244.97:56909
// [17:42:56.055] [ERROR] [USERS] Couldn't authenticate user: John Doe USER_NOT_FOUND
// [17:42:56.072] [WARN] [NETWORK] Connection closed: 85.184.244.97:56909 Disconnected
// in all.log
// {"timestamp":1677355019642,"level":"INFO","component":"NETWORK","source":null,"msg":["New connection:","85.184.244.97:56909"]}
// {"timestamp":1677355020055,"level":"ERROR","component":"USERS","source":null,"msg":["Couldn't authenticate user:","John Doe","USER_NOT_FOUND"]}
// {"timestamp":1677355020072,"level":"WARN","component":"NETWORK","source":null,"msg":["Connection closed:","85.184.244.97:56909","Disconnected"]}
// in error.log
// {"timestamp":1677355020055,"level":"ERROR","component":"USERS","source":null,"msg":["Couldn't authenticate user:","John Doe","USER_NOT_FOUND"]}

Keywords

logging

FAQs

Package last updated on 01 May 2023

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