-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
55 lines (45 loc) · 1.18 KB
/
example.js
File metadata and controls
55 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* example.js
*
* Example node.js script to show off the consolelog module capabilities
*
* To run:
* node example.js
*
* by Chad Etzel - December 11, 2009
*
* Hacker License:
* Feel free to hack at will
*/
var sys = require("sys"),
cl = require("./consolelog");
cl.tc.resetTerminal();
sys.puts("Running termcolor standard test function...");
sys.puts("");
cl.tc.test();
sys.puts("Running consolelog standard test function...");
sys.puts("");
cl.test();
sys.puts("");
sys.puts("Showing other consolelog functionality");
sys.puts("");
cl.log("8 + 8 = " + (8 + 8));
cl.puts('consolelog.puts is aliased to log for convenience');
cl.info("node.js is nifty");
cl.setLogPrefix("log: ");
cl.log("this message has a new prefix string");
cl.setAllPrefix(function() {
var d = Date.now();
return "[" + d + "] ";
});
cl.log("prefixes can be functions, too");
cl.warn("this should also show the timestamp");
cl.info("the error() function is handy for showing errors...");
try {
var j = thisDoesNotExist();
} catch(e) {
cl.error("An Error Occured:\n" + e.stack.toString());
}
cl.restoreDefaults();
cl.info('the end!');
cl.log('hope you find this useful!!');