Skip to content

Instantly share code, notes, and snippets.

@the-teacher
Created October 18, 2012 07:13
Show Gist options
  • Save the-teacher/3910259 to your computer and use it in GitHub Desktop.
Save the-teacher/3910259 to your computer and use it in GitHub Desktop.
JS/Coffee logger
@trace_mode = false
# _log - global log - выводит сообщения всегда
# log - выводит сообщения везде кроме production
# trace - выводит сообщения только если включен флаг trace_mode
# report - отправляет AJAX на сервер с сообщением
@_log = -> console.log.apply(console, arguments)
@log = -> _log.apply(console, arguments) unless env.production()
@trace = -> _log.apply(console, arguments) if trace_mode
@report = -> 'send AJAX to server'
# IE fix
if $.browser.msie
@_log = Function.prototype.bind.call(console.log, console)
@log = ->
@trace = ->
@log = Function.prototype.bind.call(_log, console) unless env.production()
@trace = Function.prototype.bind.call(_log, console) if trace_mode
# TestCase
# _log '_log'
# log 'log'
# trace 'trace'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment