Skip to content

fed135/Logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logger

Build Status NPM Bower

What is Logger?

Logger is a logging utility for your browser. Ever encountered one or more of these issues:

  • Need defined (and perhaps customizable) log levels
  • Need ability to mute certain levels logging on certain environements
  • Need to pipe your error logs to a tracking service
  • Need more color and liveness in your console
  • Need prettier error statements

Logger aims to solve ALL of these issues and more! It's a library that is build next to the browser's default console and does not override it. It can be loaded as an AMD module or used globaly.

logger

And it's super light: 1.74Kb (minified)!

Compatibility

Browser Compatibility
Chrome Yes
Firefox Yes
IE / Edge Yes
Opera Yes
Safari Yes

Releases

Static

Latest release

All releases

NPM

$ npm install console-logger.js

Bower

$ bower install logger.js

Usage

Simply import the minified/unminified script from dist, then start configuring:

Loading the module

// If requireJS or another AMD-compatible loader is detected:
require('logger', function(logger) {
    logger.log('Hello there!');
});

// Or else, it should be available through the global namespace:
window.logger.log('Bloody hell!');

Creating log levels

// I want an error level for when stuff explodes
logger.add('critical', {
	style: 'color:purple;font-weight:bold;'
});

Selecting levels

// I want to mute everythin in Production
logger.select('*').mute();	// Mutes all the channels

Piping

// I want to send errors and criticals to my tracking service
logger.select(['error', 'critical']).pipe(myTrackingService);

Changing the style

// I want error logs to be sassier
logger.select('error').style('color:pink;text-shadow:1px 1px 0px rgba(0,0,0,0.4)');
// I can use CSS styling!

Actually printing stuff

logger.log('This is a log!');
logger.warn('This is a warning!');
logger.error('This is an error!');
// These 3 are created by default

Compiling

Running gulp will compile new minified and minifed versions.

Testing

Running gulp test will launch the test sequence.

Roadmap

Milestones