npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@brainstack/log

v1.1.150

Published

A Micro Logger Package

Downloads

44

Readme

@brainstack/log

Description

@brainstack/log is a logging package that provides a flexible and customizable logger for your JavaScript or TypeScript projects. It allows you to manage log levels and integrate with various logging systems.

The package provides the following abstractions:

LoggerIntegration

Represents a logger integration that provides methods for logging messages at different levels.

  • log(message: any): void: Logs a general message.
  • info(message: any): void: Logs an informational message.
  • warn(message: any): void: Logs a warning message.
  • error(message: any): void: Logs an error message.
  • verbose(message: any): void: Logs a verbose message.

Logger

Represents a logger that manages log levels and integrations for logging messages.

  • integrations: LoggerIntegration[]: The logger integrations.
  • level: number: The current log level.
  • changeLogLevel(level: number): void: Changes the log level of the logger.
  • addIntegration(integration: LoggerIntegration): void: Adds a logger integration.
  • removeIntegration(integration: LoggerIntegration): void: Removes a logger integration.
  • log(message: any): void: Logs a message.
  • info(message: any): void: Logs an informational message.
  • warn(message: any): void: Logs a warning message.
  • error(message: any): void: Logs an error message.
  • verbose(message: any): void: Logs a verbose message.

Features

  • Flexible log level management.
  • Customizable logger integrations.
  • Supports logging at different levels: log, info, warn, error, verbose.

Getting Started

Installation

You can install the @brainstack/log package using npm:

npm install @brainstack/log

or yarn:

yarn add @brainstack/log

Usage

Here's an example of how to use the @brainstack/log package:

import { createLogger, consoleIntegration } from '@brainstack/log';

// Create a logger with a log level and integration
const logger = createLogger(3, [consoleIntegration]);

// Log messages at different levels
logger.log('This is a log message');
logger.info('This is an info message');
logger.warn('This is a warning message');
logger.error('This is an error message');
logger.verbose('This is a verbose message');

Use Case Walkthrough

Here's a walkthrough of a common use case for the @brainstack/log package:

  1. Install the package using npm or yarn.
  2. Import the necessary modules from @brainstack/log.
  3. Create a logger using the createLogger function, specifying the log level and any desired integrations.
  4. Use the logger to log messages at different levels using the provided methods (log, info, warn, error, verbose).

Contributing

Contributions to @brainstack/log are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.

License

This package is licensed under the MIT License.