X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/b157bbf02932396c65c0aca9638c96200c4665df..affc845a8af21ea11ea4f500ed06ea2d1f8ea53d:/project/static/js/jquery.logging.js diff --git a/project/static/js/jquery.logging.js b/project/static/js/jquery.logging.js new file mode 100644 index 00000000..02e10e40 --- /dev/null +++ b/project/static/js/jquery.logging.js @@ -0,0 +1,35 @@ +(function($) { + const LEVEL_DEBUG = 1; + const LEVEL_INFO = 2; + const LEVEL_WARN = 3; + + const LOG_LEVEL = LEVEL_DEBUG; + + var mozillaLog = function(msg) { + if (console) console.log(msg); + }; + + var operaLog = function(msg) { + opera.postError(msg); + }; + + var defaultLog = function(msg) { return false; }; + + $.log = function(message, level) { + if (level == null) level = LEVEL_INFO; + if (message == null) message = 'TRACE'; + if (level < LOG_LEVEL) + return false; + + return $.log.browserLog(message); + }; + + if ($.browser.mozilla || $.browser.safari) + $.log.browserLog = mozillaLog; + else if($.browser.opera) + $.log.browserLog = operaLog + else + $.log.browserLog = defaultLog; + + +})(jQuery);