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

logz-js

v0.2.2

Published

Configurable logger with a buffer to pipe logs to a server

Downloads

10

Readme

LogZ Build Status Dependency Status devDependency Status NPM

A javascript template library that you define the html and template functions in a JSON.

NPM

$ npm install logz-js

Bower

$ bower install logz

Usage

Basic

var logz = LogZ();

logz.log("test");
logz.info("test: %s", "string");
logz.warn("test: %d", 123);
logz.error("test error: %d", 123);

Basic

var logz = LogZ();

logz.log("test");
logz.info("test: %s", "string");
logz.warn("test: %d", 123);
logz.error("test error: %d", 123);

Buffered Output

var logz = LogZ("basic", {
    env: "dev",
    showTrace: true,
    buffer: {
        size: 8,
        showTrace: true
    }
});

console.log("----------------------------------------------------------");
console.log("-- Log Output --");
console.log("----------------------------------------------------------");
logz.log("test");
logz.info("test: %s", "string");
logz.warn("test: %d", 123);
logz.error("test error: %d", 123);

logz.log("before group");

logz.group();
    logz.log("test log", "Group", 1);
    logz.warn("test warn", { obj: "Group1" } );

    logz.group("test 2");
        logz.log("test", "Group", 2);
        logz.warn("test", { obj: "Group2" } );
    logz.groupEnd();
logz.groupEnd();

logz.log( { after: "group", a: [1,2,3,4,5,6,7,8,9,0] } );

console.log("----------------------------------------------------------");
console.log("-- Dumping Buffered Output --");
console.log("----------------------------------------------------------");
var dump = logz.dump();

console.log("----------------------------------------------------------");
console.log("-- Printing Buffered Output --");
console.log("----------------------------------------------------------");
console.log( dump.join("\n") );

Custom Format

var logz = LogZ("basic", {
    display: true,
    formatFunc: function(lz, args) {
        var out = [];
        var a = 0;

        // add time
        var td = moment().format('YYYY-MM-DD HH:mm:ssZ');

        // if first arg is string add time to it to support % replacement
        if(typeof args[0] === "string") {
            out.push( "["+td+"] "+lz.name+" - " + args[0] );
            a++;
        } else {
            out.push("["+td+"] "+lz.name+" - ");
        }

        // add args
        for(; a < args.length; a++) {
            // if show time, and first item
            out.push( args[a] );
        }

        return out;
    }
	,buffer: {
		size: 8,
        showTrace: true,
        formatFunc: function(lz, log) {
            var out = [];
            var a = 0;

            // add time
            var td = moment(log.time).format('h:mm:ss a');

            // if first arg is string add time to it to support % replacement
            if(typeof log.args[0] === "string") {
                out.push( td + " - " + log.args[0] );
                a++;
            } else {
                out.push(td + " - ");
            }

            // add args
            for(; a < log.args.length; a++) {
                // if show time, and first item
                out.push( log.args[a] );
            }

            // show trace
            if(log.trace) {
                out.push("-> " + log.trace );
            }

            return out;
        }
	}
});

console.log("----------------------------------------------------------");
console.log("-- Log Output --");
console.log("----------------------------------------------------------");
logz.log("test");
logz.info("test: %s", "string");
logz.warn("test: %d", 123);
logz.error("test error: %d", 123);

logz.log("before group");

logz.group();
    logz.log("test log", "Group", 1);
    logz.warn("test warn", { obj: "Group2" } );
    logz.trace("test trace", { obj: "Group3" } );

    logz.group("test 2");
        logz.log("test", "Group", 2);
        logz.warn("test", { obj: "Group2" } );
    logz.groupEnd();

logz.groupEnd();

logz.log( { after: "group", a: [1,2,3,4,5,6,7,8,9,0] } );

console.log("----------------------------------------------------------");
console.log("-- Dumping Buffered Output --");
console.log("----------------------------------------------------------");
var dump = logz.dump();

console.log("----------------------------------------------------------");
console.log("-- Printing Buffered Output --");
console.log("----------------------------------------------------------");
$('#logz').append(dump.join("\n"));

Tests

Mocha

$ npm test

Karma

$ npm run-script test-browser