Name: simple-console
Owner: Formidable
Description: A small, cross-browser-friendly console wrapper.
Created: 2015-02-27 16:56:12.0
Updated: 2017-09-19 13:24:51.0
Pushed: 2015-04-04 14:02:45.0
Homepage: null
Size: 320
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Provides a simple, but useful cross-browser-compatible console
logger.
.apply
and .bind
usage with console.OPERATION
.Install via npm:
m install simple-console
or bower:
wer install simple-console
Import the SimpleConsole
class into your code (via AMD, CommonJS, etc) and
use as a drop-in replacement for console.OPERATION
. Creating a new object
does not effect the existing window.console
object.
ne(["simple-console"], function (SimpleConsole) {
r con = new SimpleConsole();
n.log("Hello world!");
SimpleConsole = require("simple-console");
con = new SimpleConsole();
log("Hello world!");
In your HTML:
Option One: Minified -->
ipt src="PATH/TO/simple-console/dist/simple-console.min.js"></script>
Option Two: Raw source -->
ipt src="PATH/TO/simple-console/simple-console.js"></script>
In your JS:
con = new window.SimpleConsole();
log("Hello world!");
There are some cases where you will want to conditionally silence the logger.
You can do this by passing setting the noop
option:
con = new SimpleConsole({ noop: true });
log("Hello world!"); // => Should _not_ output anything.
This is usually useful in a case where you build different capabilities based on some external information, for example, React-style, this could be something like:
con = new SimpleConsole({
op: process.env.NODE_ENV === "production"
log("Hello world!"); // => Should _not_ output anything in `production`.
If you are looking to polyfill console
, then you can:
SimpleConsole({ patch: true });
This will mutate the window.console
object in ways that are not easily
undone, so consider this a “one way” patch. Moreover, if window.console
does not exist, it will create the object.
You can even go further and patch and noop the logger with:
SimpleConsole({ patch: true, noop: true });
which ensures that nothing logs anything.
Note: In addition to filling/patching missing behavior, the polyfill will
replace behavior that already exists and works. This is presently due to
complexities likely normalizing and ensuring things like .bind
, .apply
and .call
work on all log methods.
Run checks, then development server:
lp
Separated:
lp check
lp dev
Execute the demo code:
de examples/demo.js
antomjs examples/demo.js
Navigations:
Release process:
package.json
, bower.json
npm run-script everything
HISTORY.md
gulp check:all
Similar projects that can help with console
:
Copyright 2015 Formidable Labs, Inc. Released under the MIT License,