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

@thaerious/logger

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thaerious/logger

A compact NodeJS module to manage application logging. Designed to be easy to use with minimal (currently none) external dependencies.

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Node Logger

A compact NodeJS module to manage application logging. Designed to be easy to use with minimal (currently none) external dependencies.

Installation

To install using npm:

    npm i @thaerious/logger

Quick Start

The default behaviour provides a single channel called 'log' which outputs to the console. Inovking the channel as a function will process the passed in values.

    import Logger from "@thaerious/logger";
    const logger = new Logger();
    logger.log("hello world");

Adding Channels

Using a previously undefined channedl will create a new channel that outputs to the console.

    logger.verbose("ima debug statement!");

Disabling a Channel

Setting the enabled field on a channel to false will prevent all processing on that channel. To enable the channel set the enabled field to true.

    logger.log.enabled = false;
    logger.log.enabled = true;

Add Custom Handlers

When a channel receives input it is sent through a chain of handlers. The default is a single handler that outputs the input to the console verbatim.

A handler can either be a callback function or an object with a log function, such as console or another channel.

The callback function accepts 2 arguments: value, raw. The value argument is the value returned by the previous handler. The raw is the original object value into the channel. Note, the first handler receives the same value for both value and raw. The channel will return the result of the last handler.

Pass an array of handlers to handlers setter to set handlers, this will erase all previous handlers. Alternatively use #clearHandlers, prependHandler, or appendHandler.

logger.log.handlers = [
    (v) => `[log] ${v}`,
    someHandler,
    console
]

To prepend handlers, pass in the previous handlers.

logger.log.handlers = [
    (v) => `[log] ${v}`,
    someHandler,
    this.handlers
]

FAQs

Package last updated on 14 Apr 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

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