Created
May 24, 2013 09:54
-
-
Save bitsprint/5642503 to your computer and use it in GitHub Desktop.
Console Logger
This file contains hidden or 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
| var App = App || { }; | |
| (function (factory) { | |
| 'use strict'; | |
| if (typeof define === 'function' && define.amd) { | |
| // Register as an anonymous AMD module: | |
| define([ | |
| 'jquery', | |
| 'App' | |
| ], factory); | |
| } else { | |
| // Browser globals: | |
| factory(window.jQuery, App || {}); | |
| } | |
| }(function ($, App) { | |
| 'use strict'; | |
| App.ConsoleLogger = function(options) { | |
| if (!(this instanceof App.ConsoleLogger)) | |
| throw new Error('Constructor invoked as a function!'); | |
| if (typeof console === 'undefined' || !console.log) | |
| throw 'This browser version does not support a debugging console, please use an alternative Logging Provider.'; | |
| this.defaults = { }; | |
| this.settings = $.extend({}, this.defaults, options); | |
| }; | |
| App.ConsoleLogger.prototype = function() { | |
| return { | |
| debug: function (message) { | |
| if (console.debug) { | |
| console.debug(message); | |
| } else { | |
| console.log('DEBUG - ' + message); | |
| } | |
| } | |
| , error: function (message) { | |
| console.error(message); | |
| } | |
| , fatal: function (message) { | |
| console.error('ERROR -', message); | |
| } | |
| , info: function (message) { | |
| console.info(message); | |
| } | |
| , log: function (message) { | |
| console.log(message); | |
| } | |
| , trace: function (message) { | |
| console.trace(); | |
| } | |
| , warn: function (message) { | |
| console.warn(message); | |
| } | |
| }; | |
| }(); | |
| })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment