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

@punkish/zlogger

v1.0.9

Published

a very, very zimple logger

Downloads

4

Readme

zlogger

a realy zimple logger

There are a lot of wonderful loggers that do a lot of things. This is not one of them. This is a zero-dependency, 3.9KB (135 lines), synchronous logger, basically just a wrapper around process.stdout.write. It has loglevels and transports and can output log in color.

  1. import the logger class. If your script is in a CommonJS format, rename it with .mjs extension.

    import { Zlogger } from '@punkish/zlogger';
  2. create a new logger with options

    const log = new Zlogger({
    
        // every log line gets decorated with the name.
        // there is no default value
        name: 'MAIN', 
    
        // log levels can be
        //  'debug', 'info', 'warn', 'error', 'fatal'
        //  'info' is the default log level
        level: 'info', 
    
        // transports are where the log is written
        //   'console' always exists in development
        //   'file' is optional
        transports: [ 'console', 'file' ],
    
        // 'mode' is optional and chooses between streams and appendFile,
        // defaulting to streams if none is provided
        mode: 'streams',
    
        // 'dir' is optional and used when transport is 'file'
        // if no 'dir' is provided then 'logs' is used
        dir: 'path/to/logdir'
    });
  3. log away

    log.info(`logger level is ${log.level()}`);
    log.info('foo');
    log.info('hello… ', 'start');
    log.info('done\n', 'end');
    log.warn('oops');
    log.error('uh oh!');
    log.fatal('died');

    The optional 'start' and 'end' position flags output the log message on the same line (in this case, you have to add the \n newline explicitly when the 'pos' is 'end'). In the example shown above, the output will be

    2022-02-28 20:09:15.240 MAIN – INFO  logger level is FATAL
    2022-02-28 20:09:15.240 MAIN — INFO  foo
    2022-02-28 20:09:15.240 MAIN — INFO  hello… done
    2022-02-28 20:09:15.241 MAIN — WARN  oops
    2022-02-28 20:09:15.241 MAIN — ERROR uh oh!
    2022-02-28 20:09:15.242 MAIN — FATAL died