Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
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
Otherwise, download either bows.js or bows.min.js.
localStorage.debug = /Foo/
to only display logs for modules matching the regex to help you focus in development.
localStorage.debug ='!/Foo/
localStorage.andlogKey
and you can use localStorage.<anyKeyYouWant>
to set your log grepping.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 = bows("My App", "[ChuckNorris]");
log("Kicks ass!");
//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 delete localStorage.debugColors
. //Should be set in your console to see messages
localStorage.debug = true
//Configure the max length of module names (optional)
bows.config({ padLength: 10 })
var logger1 = bows('Module 1')
var logger2 = bows('Module 2')
var logger3 = bows('Module 3')
logger1("We started up")
logger2("We did something too")
logger3("I'm here")
logger3("I'm still here")
logger2("I'm tired")
logger1("We're done here")
Result:
This project uses phantomjs
for tests. To run the tests install the development dependencies and then run:
npm test
Add a file in test
, refer to enabled.html/disabled.html, then add the script to the array in test/index.js.
MIT
Copyright @philip_roberts / latentflip.com.
With contributions from:
Bows depends on andlog, a nice little logging module by @HenrikJoreteg.
Please feel free to raise issues, or make contributions:
git clone https://github.com/latentflip/bows.git
cd bows
npm install #install dependencies
#edit bows.js
npm test
npm run build.js #build dist/bows.js and dist/bows.min.js, also done by `npm test`
FAQs
Rainbowed console logs for chrome, opera and firefox in development.
The npm package bows receives a total of 1,096 weekly downloads. As such, bows popularity was classified as popular.
We found that bows demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.