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

logardian

v4.0.0

Published

Minimalistic, fast, powerful node.js logger

Downloads

64

Readme

Logardian

Inspired by NestJS Logger, Logardian was built to output minimalistic, readable logs.

Roadmap

  • [x] Async hooks
  • [x] NodeJS v16.17.1
  • [ ] Logging to file

Installation

Note: Logardian with version 3.0.0 or higher requires NodeJS 16+ because of async hooks. If you don't want them downgrade to version 2.1.0

npm i --save logardian

Features

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

  • OpenTelemetry trace ID support

  • In production mode debug() does not work

  • Datetime in UTC format

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

  • In debug mode the path and name of the function that called the log is displayed

  • 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({
    trace: false,
    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

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

Labels

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

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

OTEL Trace IDs

Use trace ID from your OTEL

// your create user logic

logger.log('User has been created')
// [2022-10-05 11:34:41.621] [7a22fdae427ddd12ace3a129e344121b] log: User has been created
//                                    ^ unique trace id

// your send email for user logic here

logger.log('Email for user was sent')
// [2022-10-05 11:34:47.317] [7a22fdae427ddd12ace3a129e344121b] log: Mail for user was sent
//                                    ^ same trace id

const traceId = logger.getTraceId()
// 7a22fdae427ddd12ace3a129e344121b

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 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
})

I do not want to see caller and path. How can I turn off them globally?

Specify 'false' on logardian config. If you specify trace: true in logger function trace will log in spite of config option

Priority of trace from high to low:

  1. Production mode
  2. logger.log('Hello', { trace: true })
  3. logger.configure({ trace: false })

License

MIT