Rainbowed console logs for chrome, opera and firefox in development.
Safe, production happy, colourful logging - makes reading your logs much easier.
(Rain)bows makes logging debug messages in your apps much nicer.
If you are using browserify, you'll want something like:
npm install bows --save
If you use Bower:
bower install bows --save
localStorage.debug = /Foo/to only display logs for modules matching the regex to help you focus in development.
Works great in browserify and the browser.
Creating a new logger:
var log = require('bows')("My Module Name")
var log = bows("My Module Name")
Then using it is easy:
log("Module loaded") //-> "My Module Name | Module Loaded"
log("Did something") //-> "My Module Name | Did something"
Typically each seperate module/view/etc in your app would create it's own logger. It will be assigned it's own color to make it easy to spot logs from different modules.
You can pass additional arguments to
bows which will be automatically prepended to each message, e.g.:
var log = ;;//outputs://My App | [ChuckNorris] Kicks ass!
Logging is disabled by default. To enable logging, set
localStorage.debug = true in your console and refresh the page.
To disable logging again, you must do
delete localStorage.debug (
localStorage.debug = false will not work).
You can leave the code in in production, and log() will just safely no-op unless localStorage.debug is set.
Where colors are not supported, bows will just log plain text, but still with the module prefix.
localStorage.debugColors = false, to reenable
//Should be set in your console to see messageslocalStoragedebug = true//Configure the max length of module names (optional)bowsvar logger1 =var logger2 =var logger3 =
This project uses
phantomjs for tests. To run the tests install the development dependencies and then run:
Add a file in
test, refer to enabled.html/disabled.html, then add the script to the array in test/index.js.
With contributions from:
Please feel free to raise issues, or make contributions:
git clonecd bowsnpm install #install dependencies#edit bows.jsnpm testnpm run build.js #build dist/bows.js and dist/bows.min.js, also done by `npm test`