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

@yaupon/logger

v0.0.0-dev.2

Published

🪵 A logger for Node.js that uses Pino and cls-hooked to provide structured logging and context propagation.

Downloads

7

Readme

🪵 Logger

Well-designed abstraction for logging compatible with major HTTP frameworks and logging libraries, including: winston, pino, bunyan and log4js. It provides a simple and consistent API for logging in yaupon ecosystem.

Features

  • Various formats of logs including: pretty, ndjson, syslog
  • Easy integration into existing apps with OOB support for log metadata such as User's ID, Request ID, etc.

API

  • Logger(options?: LoggerOptions): Logger - creates a new logger instance.
  • createLogger(options?: LoggerOptions): Logger - creates a new logger instance.
  • each logger instance has the following methods:
    • trace(message: string, meta?: Record<string, any>): void
    • debug(message: string, meta?: Record<string, any>): void
    • info(message: string, meta?: Record<string, any>): void
    • warn(message: string, meta?: Record<string, any>): void
    • error(message: string, meta?: Record<string, any>): void
    • fatal(message: string, meta?: Record<string, any>): void
    • child(meta: Record<string, any>): Logger - creates a child logger with the provided metadata.
  • setContext(meta: Record<string, any>): void - sets the global context for the logger.
  • setGlobalLogger(logger: Logger): void - sets the global logger for the application. (Overrides console.log and console.error)
  • @logthis - decorator for logging class methods and fuctions for debugging purposes, in future this will be replaced with @yaupon/debug package with @debug decorator.
  • log.<level>('message') - logs a message with the global logger.

Tasklist

  • [ ] Replaceable structure of logs metadata which would provide type-safety and consistency for produced logs.

  • [ ] Add easy interface to integrate popular tools such as NewRelic, OpenTelemetry and so on, all this should be provided as separate package which will be imported into LoggerOptions.integrations field by using default export from integration package ex. import newrelic from '@yaupon/logger-provider-newrelic'.

  • [ ] Self-linting which will include warnings for every log message that was malformed or have insufficient information (and such linting shouldn't apply to logs from global logger which replaced console.log and console.error).

  • [ ] @yaupon/logger-provider-native-yaupon library which will provide native integration with yaupon ecosystem, this will apply additional overrides which will allow parsing information from structures in application like Request, Response, Context and so on, leading to more simplified and consistent logging. Eventually usage would look like logger.info(event) and the detailed logs will be automatically mapped and structured.

  • [ ] Add support for @yaupon/debug package.

  • [ ] Add support for @yaupon/audit package.

  • [ ] Add support for @yaupon/monitoring package.

  • [ ] Add support for @yaupon/telemetry package.

  • [ ] Add support for @yaupon/tracing package.

Usage

import { Logger, createLogger, log } from '@yaupon/logger';

const logger: Logger = createLogger();

logger.info('Hello, world!');
logger.child({requestId: '123' }).info('Hello, world!');

log("Smth, happended")
log("Look this is a function", createLogger)

@logthis
class MyClass {
  @logthis
  public myMethod() {
    return 'Hello, world!';
  }
}