
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
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,182 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
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.