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

get-off-my-log

v0.1.0

Published

My JavaScript logging library for node and browser. Probably lamer than the other log libraries, but this one is mine so nerr.

Readme

Get off my log!

Build status

My JavaScript logging library for node and browser. Probably lamer than the other log libraries, but this one is mine so nerr.

Does the world really need another logging library?

Absolutely, definitely, resoundingly no, it does not.

Should I use this library instead of something else?

Almost certainly no, you should use something else instead of this library.

What does this library offer?

It is fully supported by unit tests, is small of interface and implementation, and works in both node.js and the browser.

Furthermore, it behaves exactly how I want, which is quite important when you're me.

What size is it?

2.6 kb unminified with comments, 0.7 kb minified, 0.4 kb minified + gzipped

How do I install it?

Any of the following will do:

npm install get-off-my-log

jam install get-off-my-log

bower install get-off-my-log

component install philbooth/get-off-my-log

git clone [email protected]:philbooth/get-off-my-log.git

How do I use it?

Loading the library

If you are running in Node.js, Browserify or another CommonJS-style environment, you can require get-off-my-log like so:

var log = require('get-off-my-log');

It also the supports the AMD-style format preferred by Require.js:

require.config({
    paths: {
        log: 'get-off-my-log/src'
    }
});

require([ 'log' ], function (log) {
});

If you are including get-off-my-log with an HTML <script> tag, or neither of the above environments are detected, get-off-my-log will just export its interface globally as log.

Calling the exported functions

Before logging any data, you must initialise the library with an origin string, using the initialise function:

var fooLog = log.initialise('foo');

The benefit of this step is that it enables straightforward searching and filtering of log files if you are running a project where you wish to differentiate between the origins of different log messages:

var userLog, systemLog;

userLog = log.initialise('user');
systemLog = log.initialise('system');

There is also a second, optional argument to initialise, the logger function. If it is undefined, it defaults to console.log. However, if you would like to, say, log messages to a file rather than the console, providing a custom logger enables you to do that:

var userLog, systemLog;

userLog = log.initialise('user', userLogger);
systemLog = log.initialise('system', systemLogger);

function userLogger (message) {
    fs.writeFileSync(logs.user, message + '\n');
}

function systemLogger (message) {
    fs.writeFileSync(logs.system, message + '\n');
}

Regardless of how you choose to initialise your logger(s), each one is returned from initialise as an object with three methods: info, warn and error.

Each of these methods takes one argument, the message that you want to log. The message will be sent to the appropriate logger function (or console.log if you used the default), prefixed with a timestamp, the log level of the method (either INFO, WARN or ERROR), and the origin that you set in the call to initialise.

Examples

var resizeLog, isFired, isDrawing;

// Initialise the window resize logger
resizeLog = log.initialise('resize');

isFired = isDrawing = false;

window.addEventListener('resize', throttleResize, false);

function throttleResize () {
    if (isDrawing === false) {
        isFired = true;
        draw();
    } else {
        // Write warning-level message to the console
        resizeLog.warn('already drawing');
    }
}

function draw () {
    if (isFired === true) {
        isFired = false;
        isDrawing = true;

        // Write info-level message to the console
        resizeLog.info('started drawing');

        // Draw...

        requestAnimationFrame(draw);
    } else {
        isDrawing = false;

        // Write info-level message to the console
        resizeLog.info('stopped drawing');
    }
}
var log, databaseLog;

log = require('get-off-my-log');

// Initialise the database logger
databaseLog = log.initialise('database', databaseLogger);

function databaseLogger (message) {
    fs.writeFileSync('/var/log/foo/database.log', message);
}

function update (query, data) {
    // Write info-level message to database log file
    databaseLog.info('updating ' + query + ' with ' + data);

    // Update datbase...

    if (error) {
        // Write error-level message to database log file
        databaseLog.error(error.message);
    }
}

How do I set up the build environment?

The build environment relies on Node.js, JSHint, Mocha, Chai and UglifyJS. Assuming that you already have Node.js and NPM set up, you just need to run npm install to install all of the dependencies as listed in package.json.

The unit tests are in test/index.js. You can run them with the command npm test. To run the tests in a web browser, open test/index.html.

What license is it released under?

MIT