Socket
Socket
Sign inDemoInstall

@jacraig/woodchuck

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jacraig/woodchuck

A simple logging library.


Version published
Weekly downloads
14
decreased by-46.15%
Maintainers
1
Install size
93.1 kB
Created
Weekly downloads
 

Changelog

Source

1.1.1 (2024-04-14)

Bug Fixes

  • Package updates (79e7a7d)

Features

  • Adding BatchedSink and BatchedSinkOptions (c51e5ca)

Readme

Source

WoodChuck - Logging Library

NPM Publish

WoodChuck is a versatile logging library for TypeScript/JavaScript that simplifies the process of logging messages within your applications and is built with structured event data at its heart. It provides a flexible and extensible logging framework to help you track and understand the flow of your application.

Features

  • Easy Integration: Simple setup for quick integration into your projects.

  • Customizable Logging Levels: Define and use different logging levels to categorize and filter messages.

  • Extensible Plugins: Extend functionality with plugins for various output formats and destinations.

  • Structured Logging: Log structured event data to make it easier to analyze and understand.

  • Flexible Configuration: Configure the logger with a fluent interface to customize the logging experience.

Installation

npm i @jacraig/woodchuck

Usage

  1. Configure the logger with a sink to output to.

import { Logger, ConsoleSink } from '@jacraig/woodchuck';

Logger.configure()
    .minimumLevel("Information")
    .writeTo(new ConsoleSink())
    .build();

  1. Log messages with different levels:

Logger.verbose("This is a verbose message: {key}", { "key": "value" });
Logger.debug("This is a debug message: {key}", { "key": "value" });
Logger.information("This is an information message: {key}", { "key": "value" });
Logger.warning("This is a warning message: {key}", { "key": "value" });
Logger.error("This is an error message: {key}", { "key": "value" }, new Error("This is an error"));
Logger.fatal("This is a fatal message: {key}", { "key": "value" }, new Error("This is a fatal error"));

  1. Customize the logger with plugins:

Logger.configure()
    .enrichWith(new UserAgentEnricher())
    .enrichWith(new UrlEnricher())
    .enrichWith(new CallerEnricher())
    .formatUsing(new DefaultFormatter())
    .minimumLevel("Information")
    .writeTo(new ConsoleSink());

  1. Or build your own plugins:

import { LogEventEnricher, LogEvent } from '@jacraig/woodchuck';

export class MyCustomPlugin implements LogEventEnricher {
    public enrich(logEvent: LogEvent): void {
        logEvent.properties["myProperty"] = "Something, something, something, dark side";
    }
}

Contributing

If you'd like to contribute to WoodChuck, please follow our contribution guidelines.

License

WoodChuck is licensed under the Apache 2 License.

Keywords

FAQs

Last updated on 14 Apr 2024

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