updated github path
[oweals/finalsclub.git] / log.js
1
2 var util = require("util")
3
4 global.logLevel = 0
5
6 var n0 = function(n) {
7         if(n >= 0 && n < 10)
8                 return "0"+n
9         return n
10 }
11
12 global.log0 = function(s, l) {
13
14         if(s instanceof Object)
15                 s = util.inspect(s)
16
17         if(l === undefined)
18                 l = 0
19         if(l <= logLevel) {
20                 var d = new Date()
21                 var t = d.getFullYear()+"-"+n0(d.getMonth()+1)+"-"+n0(d.getDate())+"_"+n0(d.getHours())+":"+n0(d.getMinutes())+":"+n0(d.getSeconds())
22
23                 process.stdout.write(t+" "+s+"\n");
24         }
25 }
26 global.log1 = function(s) { log0(s, 1) }
27 global.log2 = function(s) { log0(s, 2) }
28 global.log3 = function(s) { log0(s, 3) }
29 global.log4 = function(s) { log0(s, 4) }
30 global.log5 = function(s) { log0(s, 5) }
31