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

@baileyherbert/logging

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baileyherbert/logging

Just another logging solution.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-35.71%
Maintainers
1
Weekly downloads
 
Created
Source

Bailey Herbert Logo

github  /  npm  /  documentation

logging

An elegant logging solution for TypeScript built on a hierarchical composite pattern.

npm install @baileyherbert/logging

examples

creating the root logger

Each application needs at least one root logger instance.

const rootLogger = new Logger();

attaching transports to the root logger

The root logger is responsible for piping its output into one or more transports. The example below will create and attach a console transport to the logger, which writes logs directly to the console. This works in a browser environment.

rootLogger.createConsoleTransport();

creating child loggers

Each service in your application should have its own logger instance. These are called child loggers, and they are used to automatically prefix output from services with their names.

const logger = rootLogger.createChild('ServiceName');

writing logs

Loggers expose methods for each supported severity level.

logger.trace();
logger.debug();
logger.info();
logger.warning();
logger.error();
logger.critical();

These methods work identically to console.log(). You can pass multiple parameters of any type, and can pass a string for formatting.

logger.info('Logged in as %s from %s', username, ip);

license

MIT

Keywords

FAQs

Package last updated on 21 Jan 2024

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