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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shelfjs/logger

v2.0.0

Published

Imagine a large application in which there is active development and something constantly needs to be debugged. The developers cover everything with debug logs and all this deploys to the server. Due to the huge number of logs, it is impossible to find

Readme

Logging

Imagine a large application in which there is active development and something constantly needs to be debugged. The developers cover everything with debug logs and all this deploys to the server. Due to the huge number of logs, it is impossible to find the log you need. Developers remove all debug logs. After a lot of logs have been removed, a bug appears in production, but now there are no logs.

How to find a balance between logs, and turn on only necessary logs?

Installation

npm i --save @shelfjs/logger

Features

Divide logs into subgroups. Break logs into subgroups. For example, authorization logs, post debug logs, notification debug logs and etc. Now, instead of removing logs from the code, you can turn logs on or off at the moment you need

  • Various labers of logs that can be turned on/off via config

  • In production mode debug() does not work

  • Datetime in UTC format

  • Format of logs: [time] [level] [label] [message]

  • Can be used instead of NestJS Logger

  • Can log any objects, arrays, variables

  • Modes: normal or json format output

  • Colors!

Usage/Examples

import { Logardian } from 'logardian'

const logger = new Logardian()

logger.configure({
    labels: ['users', '*.debug']
})

logger.log(`Hi! I'm info log example`)
logger.warn(`Hi! I'm warn log example`)
logger.error(`Hi! I'm error log example`)
logger.verbose(`Hi! I'm verbose log example`)
logger.debug({ some: 'object' })

logger.markTime('marker')

setTimeout(() => {
    logger.measureTime('marker', 'Function take {n} ms to execute')
}, 2000)

logger.log(`I will log`, { label: 'users' })
logger.log(`I will log too`, { label: 'auth.debug' })
logger.log(`I will not log :(`, { label: 'database' })

Default output

Json output

Json logs are useful to push logs in Loki or Elastic and make flexible queries

logger.configure({
    json: true
})
{"timestamp":"2022-10-10T12:39:40.012Z","message":"Starting Nest application...","level":"log"}
{"timestamp":"2022-10-10T12:39:40.017Z","message":"AppModule dependencies initialized","level":"log"}
{"timestamp":"2022-10-10T12:39:40.020Z","message":"Nest application successfully started","level":"log"}
{"timestamp":"2022-10-10T12:39:40.022Z","message":"Hi! I'm info log example","level":"log"}
{"timestamp":"2022-10-10T12:39:40.022Z","message":"Hi! I'm warn log example","level":"warn"}
{"timestamp":"2022-10-10T12:39:40.022Z","message":"Hi! I'm error log example","level":"error"}
{"timestamp":"2022-10-10T12:39:40.022Z","message":"Hi! I'm verbose log example","level":"verbose"}
{"timestamp":"2022-10-10T12:39:40.022Z","message":"{\"some\":\"object\"}","level":"debug"}
{"timestamp":"2022-10-10T12:39:40.023Z","message":"I will log","level":"log","label":"users"}
{"timestamp":"2022-10-10T12:39:40.024Z","message":"I will log too","level":"log","label":"auth.debug"}
{"timestamp":"2022-10-10T12:39:42.024Z","message":"Function take 2002.041 ms to execute","level":"timer"}

Labels

Labels now support glob patterns! You can dynamically enable and disable the logs you need via logger.configure(). For example:

Using HCP Consul KV you can dynamically change labels in your application, without restarting it

import { Logardian } from 'logardian'

const logger = new Logardian()

logger.configure({
    labels: ['users.*']
})

logger.log('User sent mail', { label: 'users.email' }) // will log
logger.log('User registered', { label: 'users.auth.registration' }) // will log
logger.log('User authorized', { label: 'users.auth.authorization' }) // will log
logger.log('Database connected', { label: 'database' }) // will NOT log
logger.log('User entity created', { label: 'database.users' }) // will NOT log

Colors

If you don't like the set of colors logardian provides you can change them in configure() function.

const logger = new Logardian()

logger.configure({
    colors: {
        timestamp: '#ABC',
        traceId: '#CCC',
        label: '#FFFFFF',
        message: '#FFFFFF',
        trace: '#FFFFFF',
        stack: '#000000'
    }
})

Environment Variables

NODE_ENV production start does not show debug() logs

FAQ

How does it implement NestJS Logger without any framework libs?

We made logger based on LoggerService but we don't explicitly import it so that we stay dependless of NestJS libraries. But you can also use the Logardian instead of common NestJS logger.

// main.ts
import { Logardian } from 'logardian'

const logger = new Logardian()

async function bootstrap(): Promise<void> {
    const app = await NestFactory.create(AppModule, { logger })

    await app.listen(port, hostname, () =>
        logger.log(`Server running at ${hostname}:${port}`),
    )
}

How can I use logardian in my NestJS service?

Simply create a new logger class

import { Logardian } from 'logardian'

@Injectable()
export class CatService {
    private readonly _logger = new Logardian()
}

I do not see NestJS logger context

Yeah, that's a problem. And for know I don't know quickfix for that

I do not see my logs with label

Specify labels you want to log or write * to log every log with label. Working in production and development mode

Logardian is a singleton, so it means that configure() works on all Logardian instances

import { Logardian } from 'logardian'

const logger = new Logardian()

logger.configure({
    labels: '*', // or ['database', 'events'] or false
    trace: false,
    json: true,
    traceId: true
})