Skip to content

Instantly share code, notes, and snippets.

@linuxsable
Created February 8, 2013 18:29
Show Gist options
  • Select an option

  • Save linuxsable/4740952 to your computer and use it in GitHub Desktop.

Select an option

Save linuxsable/4740952 to your computer and use it in GitHub Desktop.
function () {
var a = "all";
R.logger = {
_originalLog: _.isUndefined(window.console) ? R.doNothing : console.log,
_originalError: _.isUndefined(window.console) ? R.doNothing : console.error,
logQueue: [],
_log: function (a, b, c) {
a[0] = "[" + Date() + "] " + a[0], this.logQueue.unshift(a.join(" ")), this.logQueue.length >= 10 && this.logQueue.pop();
if (!c) return;
try {
jQuery.browser.msie ? b(a[0]) : b.apply(console, a)
} catch (d) {}
},
log: function () {
this._log(_.toArray(arguments), this._originalLog, a === "all")
},
error: function () {
this.
_log(_.toArray(arguments), this._originalError, a !== "none")
},
verbosity: function (b) {
if (_.isUndefined(b)) return a;
b === "all" || b === "errors" || b === "none" ? a = b : this._originalError("Invalid argument passed to R.logger.verbosity()")
},
ensureConsole: function () {
var a = _.bind(R.logger.log, R.logger),
b = _.bind(R.logger.error, R.logger);
_.isUndefined(window.console) && (window.console = {}), _.defaults(console, {
log: a,
info: a,
warn: b,
error: b,
exception: b,
assert: function (a, b) {
a || this.
error("Assertion failed: " + b)
},
dir: R.doNothing,
time: R.doNothing,
timeEnd: R.doNothing,
trace: R.doNothing
}), R.serverInfo.get("prod") && _.extend(window.console, {
log: a,
info: a,
warn: b,
error: b,
exception: b
})
}
}, R.logger.ensureConsole()
}(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment