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

mulog

v0.1.5

Published

A lightweight, worry-free and colourful logging module for console applications which supports logging to STDOUT/STDERR and a JSON file.

Downloads

2

Readme

A tiny CLI logging library.

A lightweight, worry-free and colourful logging module for console applications which supports logging to STDOUT/STDERR, a JSON-like log file or a plain text file.

Built for intuitive usage and a neat and helpful look in the terminal.

Features

  • Beautify objects and errors
  • Print buffers as hex dump
  • Tagging
  • Show timestamps and the related source file
  • Easily debug promises
  • Simple timing support for messages, functions and promises
  • Full color support
  • Log to console (with support for -v/-q arguments) or to a file

const mulog = require("mulog");
mulog.get({file:"log.txt"}) // How to set a file/change other configuration options.
const µ = mulog.get(); // Use mulog as a singleton; recommended.
// const µ = new mulog(); // Use mulog as an object.

// Basic usage
µ("Hello World");
µ.info("This is mulog, a really simple but beautiful logging library.");
µ.error("Something went wrong");
µ.warn("This is your first warning");
µ.success("The action has been completed successfully.");
µ.log("µ.log('...') is the same as µ('...')") // µlog is also chainable
 .verbose("Something less important")
 .debug("Some debug message nobody wants to read");

// Advanced stuff to log
µ("The current year is", new Date().getFullYear());
µ("Use " + require("colors/safe").red("colored text") + " from any library you like, and display beautifully formatted...", {
    "Objects": "like this one!",
    "Some stuff": 5,
    Whatever: true,
    fancy: function() { console.log("Hello World"); }
});
µ.hex("Hell\000\001World"); // hex dump, always printed on debug level

{
    // Tags (recommended syntax for tagging full files/modules)
    const µ = mulog.get().tag("hello world");
    µ.info("Now listening on localhost:8000");

    // Nested tags and chained tag syntax
    µ.tag("requests").verbose("[404] /hello-world.txt");
}

const doSomething = () => {a = 1; for (let i = 0; i < 1000000000000 * Math.random(); i++) { a = a * i; }; return a};
const doPromise = () => new Promise((resolve, reject) => setTimeout(() => Math.random() > 0.5 ? resolve("Success!") : reject(new Error("Alea iacta est")), 600));

// Promises
µ(doPromise());

// Timing (short)
µ.timer().debug(doSomething());

// Timing (as instance)
const t = µ.timer();
t.debug("Something...");
doSomething();
t.debug("...happened!");

Default configuration

const mulog = require("mulog");
const µ = mulog.get({ // Config is only applied on first initialization.
    levels: mulog.styles.DEFAULT,
    console: {
        colors: true,
        utc: true, // local timezone if false
        
        //   1   ->   2  ->    3    ->   4  ->  5  ->    6    ->   7
        // error -> warn -> success -> info -> log -> verbose -> debug
        verbosity: 5,
        respectVerbosityArgs: true, // Respect command line arguments in the format -v/-q/-vvv/-qqq/...
        
        wrap: true,
        hardWrap: false,
        indent: true
    },
    file: { // Text file output
        path: null, //"logfile.txt",
        verbosity: 100
    },
    logfile: { // JSON file output
        path: null, //"logfile.json",
        verbosity: 100
    },
    eyes: { /* Configuration for https://npmjs.com/package/eyes */ }
});

Available styles

Roadmap

  • CLI to view JSON log files, with filtering
  • proxy to different logging framework if used in a module (e.g. global.µ = mulog.proxy("winston", winston), maybe even with autodetection if possible (?))
  • ~~syslog integration~~ (this needs to be done by the process manager, e.g. Docker or SystemD)