Git Product home page Git Product logo

lumberjack's Introduction

Lumberjack

Lumberjack hijacks the browser console and enhances it so logs can be split into more manageable chunks.

Getting Started

  1. Copy lumberjack.js into your project.
  2. That's it!

What is Lumberjack?

Browser based applications with lots of JavaScript often result in lots of logging. Unfortunately, the single stream logging built into modern web browsers (through console.log) gets noisy as more and more messages are logged. In can become difficult to even follow the logs. Lumberjack aims to fix that.

Usage

Instead of logging everything with console.log, Lumberjack encourages you to split your logs into bite-sized chunks that map to your application's functionality. In Lumberjack, these are called streams. Streams organize your logging by name. For example:

console.stream('cat').info('I do not like you.');
console.stream('cat').warn('Hiss!');

console.stream('dog').info('The feeling is mutual.');
console.stream('dog').warn('Woof!');

With Lumberjack you can turn on or off logging globally or for specific sections of your code. If you don't want to hear the dog bark anymore, you can do this:

console.stream('dog').off();
//or
console.off('dog');

console.stream('dog').log('Bark! Bark! Bark!'); //this message isn't going to appear in the console

Even if you turn off a stream, all statements logged to it are still being recorded behind the scenes by Lumberjack. At any point while your application is running you can audit all the log statements like so:

console.stream('dog').logs(); //returns an Array of every message logged to the 'dog' stream

Conversely, if you want to turn a stream on, it's just as easy:

console.stream('rooster').log('qui-qui-ri-qui!'); //this message isn't going to appear in the console

console.stream('rooster').on();
//or
console.on('rooster');

console.stream('rooster').log('COCKADOODLEDOO!'); //this message will appear in the console

Lumberjack supports all the semantic console logging functions: console.log, console.info, console.dir, console.warn and console.error.

Author

Jeff Bail

License

Lumberjack is licensed under the MIT Open Source license. http://opensource.org/licenses/MIT

lumberjack's People

Contributors

jbail avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.