/*
 * @require jade.js
 */
jade.Log=function(){};
jade.Log.FACILITY_ALERT=0;jade.Log.FACILITY_CONSOLE=1;jade.Log.FACILITY_LOG4JS=2;jade.Log.FACILITY_BROKEN_CONSOLE=3;jade.Log.DEBUG=0;jade.Log.INFO=1;jade.Log.WARN=2;jade.Log.ERROR=3;jade.Log.level=-1;jade.Log.facility=null;jade.Log.logger=null;
jade.Log.print=function(a,b){var c,d,e,f,h,i,g;if(b.length)switch(jade.Log.facility){case jade.Log.FACILITY_ALERT:if(a!=jade.Log.ERROR)break;g="";i=0;if(typeof b[0]=="string"){h=b[0];i++;d=f=0;for(e=h.length;d<e;)h.charAt(d)=="%"&&"fidos".indexOf(h.charAt(d+1))>=0&&(g+=h.substring(f,d),g+=""+b[i++],d++,f=d+1),d++;g+=h.substring(f,e)}for(d=i;d<b.length;d++)g&&(g+=" "),g+=""+b[d];alert(g);break;case jade.Log.FACILITY_LOG4JS:c=[];i=0;if(typeof b[0]=="string"){h=b[0];i++;d=f=0;for(e=h.length;d<e;)h.charAt(d)==
"%"&&"fidos".indexOf(h.charAt(d+1))>=0&&(c.push(h.substring(f,d-1)),c.push(b[i++]),d++,f=d+1),d++;c.push(h.substring(f,e))}for(d=i;d<b.length;d++)c.push(b[d]);a==jade.Log.DEBUG?jade.Log.logger.debug.apply(jade.Log.logger,c):a==jade.Log.INFO?jade.Log.logger.info.apply(jade.Log.logger,c):a==jade.Log.WARN?jade.Log.logger.warn.apply(jade.Log.logger,c):jade.Log.logger.error.apply(jade.Log.logger,c);break}};
jade.Log.log=function(a){jade.Log.print(jade.Log.DEBUG,arguments)};
jade.Log.debug=function(a){jade.Log.print(jade.Log.DEBUG,arguments)};
jade.Log.info=function(a){jade.Log.print(jade.Log.INFO,arguments)};
jade.Log.warn=function(a){jade.Log.print(jade.Log.WARN,arguments)};
jade.Log.error=function(a){jade.Log.print(jade.Log.ERROR,arguments)};
jade.Log.init=function(){var a;if("console"in window&&"warn"in window.console&&("debug"in window.console||"log"in window.console)&&"error"in window.console&&"info"in window.console)try{a=window.console.log,a(),jade.Log.facility=jade.Log.FACILITY_CONSOLE,jade.Log.error=window.console.error}catch(b){jade.Log.facility=jade.Log.FACILITY_BROKEN_CONSOLE,jade.Log.error=jade.bind(window.console.error,window.console)}else"log4javascript"in window?(jade.Log.facility=jade.Log.FACILITY_LOG4JS,jade.Log.logger=
log4javascript.getDefaultLogger()):jade.Log.facility=jade.Log.FACILITY_ALERT;jade.Log.setLevel(jade.Log.ERROR)};
jade.Log.setLevel=function(a){if(jade.Log.level!=a)switch(jade.Log.level=a,jade.Log.facility){case jade.Log.FACILITY_CONSOLE:jade.Log.debug=jade.Log.isDebugLevel()?window.console.debug:jade.Log.noOp;if(!jade.Log.debug)jade.Log.debug=jade.Log.isDebugLevel()?window.console.log:jade.Log.noOp;jade.Log.info=jade.Log.isInfoLevel()?window.console.info:jade.Log.noOp;jade.Log.warn=jade.Log.isWarnLevel()?window.console.warn:jade.Log.noOp;break;case jade.Log.FACILITY_BROKEN_CONSOLE:jade.Log.debug=jade.Log.isDebugLevel()?
jade.bind(window.console.debug,window.console):jade.Log.noOp;jade.Log.info=jade.Log.isInfoLevel()?jade.bind(window.console.info,window.console):jade.Log.noOp;jade.Log.warn=jade.Log.isWarnLevel()?jade.bind(window.console.warn,window.console):jade.Log.noOp;break;case jade.Log.FACILITY_LOG4JS:jade.Log.isDebugLevel()?jade.Log.logger.setLevel(log4javascript.Level.DEBUG):jade.Log.isInfoLevel()?jade.Log.logger.setLevel(log4javascript.Level.INFO):jade.Log.isWarnLevel()?jade.Log.logger.setLevel(log4javascript.Level.WARN):
jade.Log.logger.setLevel(log4javascript.Level.ERROR)}a==jade.Log.DEBUG&&jade.Log.info("Debug logging enabled")};
jade.Log.noOp=function(){};
jade.Log.getLevel=function(){return jade.Log.level};
jade.Log.isDebugLevel=function(){return jade.Log.level==jade.Log.DEBUG};
jade.Log.isInfoLevel=function(){return jade.Log.level<=jade.Log.INFO};
jade.Log.isWarnLevel=function(){return jade.Log.level<=jade.Log.WARN};
jade.Log.init();
