Skip to content

Instantly share code, notes, and snippets.

@akisute
Created March 14, 2009 08:33
Show Gist options
  • Save akisute/79018 to your computer and use it in GitHub Desktop.
Save akisute/79018 to your computer and use it in GitHub Desktop.
var _global = this;
(function() {
function Logger(logLevel) {
this.logLevel = logLevel;
}
_global.Logger = Logger;
Logger.LEVEL_DEBUG = 0;
Logger.LEVEL_INFO = 1;
Logger.LEVEL_WARN = 2;
Logger.LEVEL_ERROR = 3;
Logger.prototype.logLevel = Logger.LEVEL_DEBUG;
Logger.prototype._dummy = function() {
return false;
};
Logger.prototype._debug = Logger.prototype._dummy;
Logger.prototype._info = Logger.prototype._dummy;
Logger.prototype._warn = Logger.prototype._dummy;
Logger.prototype._error = Logger.prototype._dummy;
try {
Logger.prototype.debug = (this.logLevel > Logger.LEVEL_DEBUG) ? this._dummy: console.debug;
Logger.prototype.info = (this.logLevel > Logger.LEVEL_INFO) ? this._dummy: console.info;
Logger.prototype.warn = (this.logLevel > Logger.LEVEL_WARN) ? this._dummy: console.warn;
Logger.prototype.error = (this.logLevel > Logger.LEVEL_ERROR) ? this._dummy: console.error;
} catch(e) {
Logger.prototype.debug = Logger.prototype._debug;
Logger.prototype.info = Logger.prototype._info;
Logger.prototype.warn = Logger.prototype._warn;
Logger.prototype.error = Logger.prototype._error;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment