Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
(function(f,c,i){if(typeof(WicketClientSideLogging)==="object"){return}i.WicketClientSideLogging={LVL_OFF:"off",LVL_ERROR:"error",LVL_WARN:"warn",LVL_INFO:"info",LVL_DEBUG:"debug",LVL_TRACE:"trace",error:function(p){this.log(this.LVL_ERROR,p,o())},errorWithoutStack:function(p){this.log(this.LVL_ERROR,p,"")},warn:function(p){this.log(this.LVL_WARN,p,"")},info:function(p){this.log(this.LVL_INFO,p,"")},debug:function(p){this.log(this.LVL_DEBUG,p,"")},trace:function(p){this.log(this.LVL_TRACE,p,"")},log:function(p,r,q){if(this.isLoggingActive(p)){m({lvl:p,stack:q,msg:r})}if(d.debug===true){this.consoleLog(p,r,q)}},consoleLog:function(p,r,q){if(i.console){var s="["+p+"] "+r;if(q&&q!=""){s+="\n"+q}if(p==="error"){if(i.console.error){i.console.error(s)}else{if(i.console.log){i.console.log(s)}}}else{if(p==="info"){if(i.console.info){i.console.info(s)}else{if(i.console.log){i.console.log(s)}}}else{if(i.console.log){i.console.log(s)}}}}},isLoggingActive:function(p){return a>0&&g(p)<=a}};var a=0;var h=[];var b=0;var d={replaceWicketLog:false,replaceWindowOnError:false,wrapWindowOnError:true,wrapWicketLog:true,flushMessagesOnUnload:true,logStacktrace:false,logAdditionalErrors:true,collectClientInfos:true,logLevel:i.WicketClientSideLogging.LVL_ERROR,url:null,method:"POST",maxQueueSize:10,loggerName:"Log",debug:false,collectionTimer:5000,collectionType:"single"};function g(p){switch(p){case i.WicketClientSideLogging.LVL_OFF:return 0;case i.WicketClientSideLogging.LVL_ERROR:return 1;case i.WicketClientSideLogging.LVL_WARN:return 2;case i.WicketClientSideLogging.LVL_INFO:return 3;case i.WicketClientSideLogging.LVL_DEBUG:return 4;case i.WicketClientSideLogging.LVL_TRACE:return 5}return 0}function m(q){q.timestamp=(new Date()).toUTCString();if(d.collectionType==="single"){e([q],true)}else{if(d.collectionType==="localstorage"){var p=amplify.store("clientside-logging");if(!p){p=[]}p.push(q);amplify.store("clientside-logging",p)}else{if(d.collectionType==="timer"||d.collectionType==="unload"){h.push(q)}else{if(d.collectionType==="size"){h.push(q);if(h.length>=d.maxQueueSize){j(true)}}else{throw new Error("invalid collection type: "+d.collectionType+"; must be one of: [single, timer, size]")}}}}}function j(q){if(d.collectionType==="localstorage"){var p=amplify.store("clientside-logging");if(p&&p.length>0){e(p,q)}}else{e(h,q)}}function e(t,r){if(!t||t.length<=0){return}r=r!==false;var s=l({}),p=1;while(t.length>0){var u=t.pop();s["timestamp_"+p]=u.timestamp;s["msg_"+p]=u.msg;s["lvl_"+p]=u.lvl;if(d.logStacktrace&&u.stack){s["stack_"+p]=u.stack}p++}f.ajax({type:d.method,url:d.url,cache:false,async:r,data:s})}function o(){if(d.logStacktrace&&i.printStackTrace){return i.printStackTrace().join("\n")}else{return""}}function l(p){p.ajaxBaseUrl=Wicket.Ajax.baseUrl||".";if(d.collectClientInfos===true){p.ua=navigator.userAgent;p.winSize=f(window).width()+"x"+f(window).height();p.screenSize=window.screen.availWidth+"x"+window.screen.availHeight}return p}var k={isManipulated:true,origWicketLog:null,override:function(p){this.origWicketLog=p;return this},enabled:function(){return this.origWicketLog.enabled()},info:function(p){i.WicketClientSideLogging.info(p);if(d.wrapWicketLog===true&&this.origWicketLog){this.origWicketLog.info(p)}},error:function(p){i.WicketClientSideLogging.error(p);if(d.wrapWicketLog===true&&this.origWicketLog){this.origWicketLog.error(p)}},log:function(p){i.WicketClientSideLogging.info(p);if(d.wrapWicketLog===true&&this.origWicketLog){this.origWicketLog.log(p)}}};function n(p){return function(t,r,q){b++;if(b==1||d.logAdditionalErrors){var s=t+" on ["+r+":"+q+"]";i.WicketClientSideLogging.errorWithoutStack(s)}if(d.wrapWindowOnError===true&&p){try{p.call(this,t,r,q)}catch(u){}}}}f.wicketClientSideLogging=function(p){d=f.extend(d,p||{});if(!d.url||d.url.length==0){throw new Error("there's no valid url set: "+d.url)}a=g(d.logLevel);if(d.wrapWindowOnError===true||d.replaceWindowOnError===true){i.onerror=n(i.onerror)}if((d.wrapWicketLog===true||d.replaceWicketLog===true)&&(!c.Log||c.Log.isManipulated!==true)){c.Log=k.override(c.Log)}if(d.collectionType==="timer"){i.setInterval(function(){j(true)},d.collectionTimer)}if(d.collectionType==="localstorage"){f(window).load(function(){i.setTimeout(function(){j(true)},500)});d.flushMessagesOnUnload=false}if(d.flushMessagesOnUnload===true||d.collectionType==="unload"){f(window).on("beforeunload",function(){j(false)})}if(d.loggerName){i[d.loggerName]=i.WicketClientSideLogging;f[d.loggerName]=i.WicketClientSideLogging}}}(jQuery,Wicket,window));
New to GrepCode? Check out our FAQ X