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

@mirekpluta/jg-logger

v1.0.8

Published

Preconfigured winston logger

Downloads

13

Readme

jg-logger

Small utility providing logger that configures winston logger for usage on local (dev) environment where readability of logs is critical as well as production, dockerized environments where logs are being processed by tools.

Installation

Simply execute

npm install @mirekpluta/jg-logger

Configuration

Logger is being configured with config npm package, therefore it requires json config files to be present in config directory.

Example config file:

{
  "logger": {
    "logLevel": "debug",
    "format": "pretty",
    "defaultMeta": {
        "serviceName": "test"
    }
  }
}

Explanation

  • logLevel - log level as specified in winston library (error, warn, info, verbose, debug, silly)
  • format
    • pretty - to be used when running locally, it displays colorized log with timestamps, padded levels and json stringified metadata + potential stacktrace in case of logged exception
    • json - it'll display each log entry as json object including timestamp and stacktrace in case of errors
  • defaultMeta - default metadata that will be included to all logs from the project

Functionality

  • both human friendly (pretty) and tools friendly (json) logs format (see Configuration above).
  • catches and logs all uncought errors (it will prevent application from exiting)
  • provides errorLoggingMiddleware express middleware to be registered at the very end with express app, that logs all rejected promises
  • uses express-async-errors package that will handle all rejected promises from middleware async functions
  • adds logger property to global object for easy access throughout entire application

Usage

Import early: - logger should be imported as early in the project as possible, so that it can be initialized

logger.errorLoggingMiddleware - express middleware that should be registered to express app as the last one

use like you would use winston logger - configured logger is just winston logger, so entire functionality of it is available.