- §1. Synopsis
- §2. Installation Instructions
- §3. Quick API Reference
- §4. Support
- §5. Change Log
- §6. Credits
- §7. License
- §8. Notes
euh.js1 is a JavaScript console wrapper that provides a simple, unified, and non-breaking way of logging across several different environments. It makes things, arguably, a little bit less painful than this:
try {
console.log("I can has cheezburger?");
} catch (e) { /* … */ }
Or this:
if (typeof console !== "undefined" && console.log) {
console.log("I can has cheezburger?");
}
Download
dist/euh.js
.
Or, with Bower:
Fire up a terminal window, and type the following command:
bower install euh.js
Then:
<script src="path/to/euh.js"></script>
See
test/euh-browser.html
for details.
Fire up a terminal window, and type the following command:
npm install euh.js
Then:
var ø = require("path/to/euh.js");
See
test/euh-node.js
for details.
Fire up a terminal window, and type the following command:
ender build euh.js
Then:
<script src="path/to/ender.js"></script>
See
test/euh-ender.html
for details.
euh.js exposes the ø
2 object—the console wrapper—to the
environment on “load”, if the environment is a browser, or on “require”, if the
environment supports CommonJS modules (e.g. Node.js).
ø.log()
ø.warn()
ø.error()
These are the core methods of ø
, and they behave pretty much like you’d
probably expect.
Additionally, they support “chaining”:
ø.log("Hi kids!").warn("Do you like chains?");
ø.enabled
You can use this boolean property to toggle logging on/off, at any time. By
default, ø.enabled
is true
.
ø.VERSION
This property can be queried to find out the current euh.js release.
euh.js is semantically versioned3. See
§5. Change Log for a brief release history.
ø.doesConsoleExist()
This function allows you to check the existence of the console
object in the
environment—There are some environments (e.g. IE 8–9 w/o F12) that don’t
provide console
straight out of the box.
ø.logs
This property stores the log messages when ø.doesConsoleExist()
is false
,
so that you can examine them when, and by whatever means you desire.
ø.fyi()
,ø.par()
,ø.pil()
—wrap aroundø.log()
ø.wtf()
,ø.wat()
,ø.wut()
—wrap aroundø.warn()
ø.omg()
,ø.omd()
—wrap aroundø.error()
ø.ln()
,ø.br()
,ø.nl()
—wrap aroundø.log()
—new lines/breaksø.ast()
,ø.sep()
—wrap aroundø.log()
—asterisms/separators
These are various alias methods that wrap around the core methods of ø
, as
specified. They can output timestamps in ISO 8601 format—An attribute that you
might find handy for basic performance tests.
ø.logTimestamps
You can use this boolean property to toggle timestamp output on/off, for the
alias methods. By default, ø.logTimestamps
is true
.
ø.noConflict()
If the environment is a browser, this method would—if called—throw euh.js into
“no conflict” mode4, and restore ø
to its previous owner, if
any.
§4. Support5
I’ve tested euh.js on the following environments:
-
Chrome “latest” (26.0.1410.63)
-
Chrome 4
-
Firefox “latest” (20.0.1)
— w/ the native console
— w/ Firebug “latest” (1.11.2) -
Firefox 3.6
— w/o console (default)
— w/ Firebug 1.7.3 -
IE 10, in all modes: IE 10, IE 10 Compat View, IE 9, IE 8, IE 7
-
IE 9
— w/o F12 (default)
— w/ F12, in all modes: IE 9, IE 9 Compat View, IE 8, IE 7 -
IE 8
— w/o F12 (default)
— w/ F12, in all modes: IE 8, IE 8 Compat View, IE 7 -
IE 7
-
IE 6
-
Safari “latest” (6.0.4) on OS X
-
Safari “latest” (5.1.7) on Windows
-
Mobile Safari on iOS 6 w/ Remote Web Inspector
-
Mobile Safari on iOS 5 w/ Debug Console
-
Opera “latest” (12.15)
-
Node.js “latest” (0.10.5)
- 1.0.0 (2012-12-22)
Changed the output of ø.ast
and ø.sep
.
The API is now “freezed”. I don’t have any plans for adding new features or
changing existing ones.
Should any issues appear, I’ll try to fix them.
- 0.4.0 (2012-12-18)
Complete rewrite.
- 0.3.1 (2012-11-10)
Made euh.js semicolon-less.
Fixed a bug where the toISOString
“shim” was being applied to a local proxy
variable instead of Date.prototype
.
- 0.3.0 (2012-06-21)
Made euh.js Ender-compatible.
Changed the output of ø.ast
and ø.sep
.
- 0.2.0 (2012-06-14)
Added timestamps to ø.fyi
, ø.par
, ø.pil
, ø.wtf
, ø.wat
, ø.wut
,
ø.omg
, and ø.omd
, toggleable via ø.logTimestamps
.
- 0.1.2 (2012-06-04)
Updated the Node.js module exports/require sections.
- 0.1.1 (2012-05-28)
Changed the output of ø.ast
and ø.sep
. The new asterism/separator style
uses less non-Latin-1 characters.
- 0.1.0 (2012-05-25)
Initial development release of euh.js.
- Cristian Tincu (@CristianTincu on GitHub and Twitter)
I made euh.js as an exercise, and as an experiment. You’re free to use it in your own exercises, experiments, or projects, whether they’re “closed” or “open”, commercial or non-commercial, “good” or “evil”, subject to the terms of the MIT License6.
Yep, “euh” (IPA: /ø/
) is an interjection.
See “euh” in Larousse.
Typing ø
on common US English keyboards is usually easier than some people
seem to be thinking:
-
⌥
+o
on Mac -
Alt
+l
on Linux -
Alt
+0248
on Windows
There are obviously fewer keystrokes required than for typing, say, console
.
Anyway, if for some particular reason you don’t agree with my naming choice,
you can do something like var whatever = ø.noConflict();
, and use whatever
from there on.
See Semantic Versioning.
I’ve borrowed this trick—as well as others—from Underscore.js.
See Underscore.js’s noConflict()
.
“Latest” means the current stable version of the respective environment, at the time I’m writing this text.
See LICENSE.md.