1 | require! {
|
2 | 'chalk' : {black, blue, bold, cyan, dim, green, magenta, red, white, yellow}
|
3 | 'prelude-ls' : {map, maximum}
|
4 | }
|
5 |
|
6 |
|
7 | class Logger
|
8 |
|
9 | (service-names) ->
|
10 | @colors =
|
11 | exocomm: blue
|
12 | exorun: -> it
|
13 | 'exo-install': -> it
|
14 | for service-name, i in service-names
|
15 | @colors[service-name] = Logger._colors[i]
|
16 | @length = map (.length), Object.keys(@colors) |> maximum
|
17 |
|
18 |
|
19 | log: ({name, text}) ->
|
20 | color = @colors[name]
|
21 | console.log color(bold "#{@_pad name} "), color(text.trim!)
|
22 |
|
23 |
|
24 | @_colors = [magenta, cyan, yellow]
|
25 |
|
26 |
|
27 | _pad: (text) ->
|
28 | " #{text}".slice -@length
|
29 |
|
30 |
|
31 | module.exports = Logger
|