]> git.gir.st - VimFx.git/blob - extension/includes/console.coffee
Closes #2. Added the Help Dialog, changed the style of the hint markers. Fixed the...
[VimFx.git] / extension / includes / console.coffee
1 console = do ->
2 cs = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
3
4 stringify = (arg) ->
5 try
6 return String(arg)
7 catch error
8 return "<toString() error>"
9
10 message = (level, args) ->
11 str = "VimFx - #{ level }: #{ Array.map(args, stringify).join(" ") }\n"
12 dump str
13 cs.logStringMessage str
14
15 expand = (arg) ->
16 if typeof(arg) == 'object'
17 str = stringify(arg)
18 for key, value of arg
19 str += "\n-\t#{ key }: #{ value }"
20
21 return str
22 else
23 return arg
24
25 return {
26 log: -> message 'log', arguments
27 info: -> message 'info', arguments
28 error: -> message 'error', arguments
29 warning: -> message 'warning', arguments
30 expand: -> message 'expand', Array.map(arguments, expand)
31 }
Imprint / Impressum