1 | require! {debug, \prelude-ls}
|
2 |
|
3 | global import prelude-ls
|
4 |
|
5 | debug.depth = 0
|
6 | debug.longuest = 0
|
7 | class Debug
|
8 |
|
9 | @depthActivated = false
|
10 |
|
11 | depthStr: ''
|
12 |
|
13 | @colors =
|
14 | cyan: debug.colors[0]
|
15 | green: debug.colors[1]
|
16 | yellow: debug.colors[2]
|
17 | blue: debug.colors[3]
|
18 | purple: debug.colors[4]
|
19 | red: debug.colors[5]
|
20 |
|
21 | (it, color = debug.colors[1], objDebug = false) ->
|
22 | @name = it
|
23 |
|
24 | debug.longuest = max debug.longuest, it.length + 7
|
25 |
|
26 | @_out = debug it + '::Log'
|
27 | ..color = debug.useColors && color
|
28 | @_outWarn = debug it + '::Warn'
|
29 | ..color = debug.useColors && @@colors.yellow
|
30 | @_outError = debug it + '::Error'
|
31 | ..color = debug.useColors && @@colors.red
|
32 |
|
33 | _DepthStr: -> ['.' for i from 0 til debug.depth]*''
|
34 | _Padding: -> [' ' for i from 0 til debug.longuest - @name.length - it]*''
|
35 |
|
36 | Log: -> @_out @_Padding(5) + @_DepthStr! + it
|
37 | Warn: -> @_outWarn @_Padding(6) + @_DepthStr! + it
|
38 | Error: -> @_outError @_Padding(7) + @_DepthStr! + it
|
39 |
|
40 | @Depth = -> debug.depth = debug.depth + 1 if @depthActivated
|
41 | @UnDepth = -> debug.depth = debug.depth - 1 if @depthActivated
|
42 |
|
43 | module.exports = Debug
|
44 |
|
45 |
|