Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@4lch4/logger

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4lch4/logger

A small utility for logging to console within NodeJS/TypeScript applications.

  • 1.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31
increased by63.16%
Maintainers
2
Weekly downloads
 
Created
Source

@4lch4/logger

This module is a small utility module for logging to stdout and, if desired, to also log to files.

Installation

The module is published to the NPM registry so you're able to install it as you would any other module:

# Using NPM
npm install --save @4lch4/logger

# Using Yarn
yarn add @4lch4/logger

# Using PNPM
pnpm install @4lch4/logger

Usage

Using the logger is fairly straight forward. Import the Logger, create a new instance with some optional properties, then use that instance throughout your application:

NOTE: You can also create new instances throughout your app and it will log to the same files/locations.

import { Logger } from '@4lch4/logger'
const logger = new Logger({
  // optional properties
})

logger.info('Hello, world!')
logger.error('Uh oh, something broke...')

Logging Levels

It has 5 "levels" of logging with a color for each, which are as follows (in no particular order):

  • debug - Cyan
  • error - Red
  • info - Gray
  • success - Green
  • warn - Yellow

If you provide a logDir when instantiating the Logger class, each level will have a file. For example, debug would be 2021.03.17-debug.log whereas error would be 2021.03.17-error.log.

Each level has a function to be called for logging at that level. For example, if you want to write to the debug level, you'd do logger.debug('Debug message').

Keywords

FAQs

Package last updated on 25 Aug 2022

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