Super-simple, client-side CommonJS logging thingy
Want to see pretty graphs? Log in now!
npm install andlog
|2||downloads in the last day|
|70||downloads in the last week|
|508||downloads in the last month|
|Last Published By|
|Version||0.0.4 last updated 10 months ago|
Super simple, but solves these pain points:
- Lets you leave log statements in production, client-side code.
- It won't log anything unless
- Uses native
consolerather than trying to wrap it in something (which makes the output ugly).
- Works with CommonJS.
- It's just a selective alias for the
window.consoleso the normal API applies.
How to use it:
Step 1. include it:
Step 2. Use the
console in your code as usual:
Step 3. If you want to see log output set a value called
localStorage by doing typing this in console:
localStorage.debug = true
Step 4. Refresh the page, you should now see logs.
Step 5. To turn off console, just delete the localStorage flag:
Step 6. Feel free to deploy to production with console stuff in there.
If you're using this on the client but your project is in node.js you can install this with: browserify and npm.
var logger = require('andlog'); logger.log('hello');
This is identical to:
You could even get fancy and call it
console. However by doing this you take the risk that you'll forget to
require it and it'll still work and you'll ship it to production. However, obviously this would work as well:
var console = require('andlog'); console.log('hello');
If you like this, follow @HenrikJoreteg on the twitterwebz.