Created
October 18, 2012 07:13
-
-
Save the-teacher/3910259 to your computer and use it in GitHub Desktop.
JS/Coffee logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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