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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hacker-und-koch/eventbus

v0.2.1

Published

* [Creating a Logger](#creating-a-logger) * [Log Levels](#log-levels) * [Line Formatting](#line-formatting) * [`LoggerBuilder`](#loggerbuilder)

Downloads

7

Readme

@hacker-und-koch/logger

Table Of Content

Creating a Logger

Builder pattern

const loggerBuilder: LoggerBuilder = Logger.build();

loggerBuilder.className('MyClass');  // manditory!

const logger: Logger = loggerBuilder.create();

logger.log('lorem ipsum');

Via Dependency Injection

import { Injectable } from '@hacker-und-koch/di';
import { Logger } from '@hacker-und-koch/logger';

@Injectable()
class MyClass {
    constructor(private logger: Logger) {
        this.logger.log('lorem ipsum');
    }
}

Log Levels

Order Of Significance

Highest to lowest:

  • error
  • warning
  • log
  • info
  • spam

Calling logger by level

logger.spam('lorem');
logger.info('ipsum');
logger.log('dolor');
logger.warn('sit');
logger.error('amet');

Line Formatting

Default formatting (example)

Above examples will print

2020-01-02T03:04:50.001Z  -  MyClass: lorem
2020-01-02T03:04:50.002Z (i) MyClass: ipsum
2020-01-02T03:04:50.003Z     MyClass: dolor
2020-01-02T03:04:50.004Z [x] MyClass: sit
2020-01-02T03:04:50.005Z !!! MyClass: amet

Overwriting FormatFunction

const formatFunction: FormatFunction = (pkg: LoggerPackage): Buffer | string => {
    const argsAsString = pkg.parts
        .map(arg => arg.toString())
        .join('+++');
    return `[${pkg.class}] ${argsAsString}\n`;
}

const logger: Logger = Logger.build()
    .className('MyClass')
    .format(formatFunction)
    .create();

logger.log('lorem', 'ipsum');

prints

[MyClass] lorem+++ipsum

LoggerBuilder

className(className: string): this

Set class name to be used when formatting log output. (( manditory! ))

@param {string:} className Class name used when formatting log output.

create(): Logger

Calling this function will finish the building process. A new instance of Logger will be created and configured according to the LoggerBuilder's state.

id(id: string): this

Set ID of instance. Is utilized by di package.

@param id: ID of instance to be used when formatting log output.

level(level: Loglevel): this

Set threshold level for Logger. Only logs with level of equal or greater importance to this value will be printed.

@param level: Threshold level for Logger

format(format: FormatFunction): this

Set Logger's FormatFunction.

@param format: Mapping function to format log lines

stdout(stream: NodeJS.WriteStream): this

WriteStream used for levels 'spam', 'info' and 'log'.

@param stream: stdout stream

stderr(stream: NodeJS.WriteStream): this

WriteStream used for levels 'warning' and 'error'.

@param stream: stdout stream

noTimestamp(): this

If called: Logger's formating function will not include a timestamp