aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.coffee
blob: 6d31f19a7d05dd331f2266b28bdcfa5121c15181 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# A simple logger class that lets you enable/disable logging to
# the console, since it can be very verbose.
class Log
  # Alias debug() to log()
  @debug: @log = -> @output "log", arguments

  # Call the console function
  @output: (method, data) ->
    if exports?
      # If we're in Node, we can call apply() on console functions
      console[method].apply null, data if PSD.DEBUG
    else
      # If we're in the browser, we have to log the array because
      # IE doesn't support calling apply() on console functions.
      console[method]("[PSD]", data) if PSD.DEBUG