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

@ecopages/logger

v0.1.3

Published

A lightweight, flexible logging library. This logger supports multiple log levels and allows for easy extension and integration into any project.

Downloads

7

Readme

@ecopages/logger

A lightweight, flexible logging library. This logger supports multiple log levels and allows for easy extension and integration into any project.

Features

  • Multiple Log Levels: Supports INFO, ERROR, WARN, and DEBUG log levels for granular control over logging output.
  • Prefixed Messages: Allows for prefixing log messages for better identification and filtering.
  • Easy to Extend: Designed with simplicity in mind, making it easy to extend or modify to fit specific requirements.

Usage

First, import the Logger class from the logger.ts file:

import { Logger } from "./path/to/logger";

Create an instance of the Logger class, optionally specifying a prefix for all log messages:

const logger = new Logger("[my-app]");

Use the logger instance to log messages at different levels:

logger.info("This is an informational message");
logger.warn("This is a warning message");
logger.error("This is an error message");
logger.debug("This is a debug message");
[my-app] This is an informational message
[my-app] This is a warning message
[my-app] This is an error message
[my-app] This is a debug message

API

Constructor

  • Logger(prefix: string): Creates a new logger instance with the specified prefix.

Methods

  • info(...args: any[]): Logs an informational message.
  • warn(...args: any[]): Logs a warning message.
  • error(...args: any[]): Logs an error message.
  • debug(...args: any[]): Logs a debug message.

Extending the Logger

To extend the logger with additional functionality, you can subclass the Logger class. For example, to add a method for logging fatal errors:

class ExtendedLogger extends Logger {
  fatal(...args: any[]) {
    // Custom implementation for fatal errors
  }
}

Debugging Instructions

By default, the debugging feature is turned off. To enable it you can provide an options object to the logger constructor.

const logger = new Logger("[my-app]", { debug: true });
[my-app] This is a debug message