UNPKG

700 BPlain TextView Raw
1require! {
2 'chalk' : {black, blue, bold, cyan, dim, green, magenta, red, white, yellow}
3 'prelude-ls' : {map, maximum}
4}
5
6
7class Logger
8
9 (service-names) ->
10 @colors =
11 exocomm: blue
12 exorun: -> it # use the default color here
13 'exo-install': -> it # use the default color here
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
31module.exports = Logger