/** * Copyright 2006 Tim Down. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ if(!Array.prototype.push){Array.prototype.push=function(){for(var i=0;i0){var firstItem=this[0];for(var i=0;i2)?itemsAfterDeleted=argumentsArray.slice(2).concat(itemsAfterDeleted):itemsAfterDeleted;for(i=0;i=minimalDaysInFirstWeek){weekInYear++}return weekInYear};Date.prototype.getWeekInMonth=function(minimalDaysInFirstWeek){if(isUndefined(this.minimalDaysInFirstWeek)){minimalDaysInFirstWeek=DEFAULT_MINIMAL_DAYS_IN_FIRST_WEEK}var previousSunday=new Date(this.getTime()-this.getDay()*ONE_DAY);previousSunday=new Date(previousSunday.getFullYear(),previousSunday.getMonth(),previousSunday.getDate());var startOfMonth=new Date(this.getFullYear(),this.getMonth(),1);var numberOfSundays=previousSunday.isBefore(startOfMonth)?0:1+Math.floor((previousSunday.getTime()-startOfMonth.getTime())/ONE_WEEK);var numberOfDaysInFirstWeek=7-startOfMonth.getDay();var weekInMonth=numberOfSundays;if(numberOfDaysInFirstWeek>=minimalDaysInFirstWeek){weekInMonth++}return weekInMonth};Date.prototype.getDayInYear=function(){var startOfYear=new Date(this.getFullYear(),0,1);return 1+Math.floor((this.getTime()-startOfYear.getTime())/ONE_DAY)};SimpleDateFormat=function(formatString){this.formatString=formatString};SimpleDateFormat.prototype.setMinimalDaysInFirstWeek=function(days){this.minimalDaysInFirstWeek=days};SimpleDateFormat.prototype.getMinimalDaysInFirstWeek=function(days){return isUndefined(this.minimalDaysInFirstWeek)?DEFAULT_MINIMAL_DAYS_IN_FIRST_WEEK:this.minimalDaysInFirstWeek};SimpleDateFormat.prototype.format=function(date){var formattedString="";var result;var padWithZeroes=function(str,len){while(str.length=4)?data:data.substr(0,Math.max(minLength,numberOfLetters))};var formatNumber=function(data,numberOfLetters){var dataString=""+data;return padWithZeroes(dataString,numberOfLetters)};var searchString=this.formatString;while((result=regex.exec(searchString))){var matchedString=result[0];var quotedString=result[1];var patternLetters=result[2];var otherLetters=result[3];var otherCharacters=result[4];if(quotedString){if(quotedString=="''"){formattedString+="'"}else{formattedString+=quotedString.substring(1,quotedString.length-1)}}else if(otherLetters){}else if(otherCharacters){formattedString+=otherCharacters}else if(patternLetters){var patternLetter=patternLetters.charAt(0);var numberOfLetters=patternLetters.length;var rawData="";switch(patternLetter){case "G":rawData="AD";break;case "y":rawData=date.getFullYear();break;case "M":rawData=date.getMonth();break;case "w":rawData=date.getWeekInYear(this.getMinimalDaysInFirstWeek());break;case "W":rawData=date.getWeekInMonth(this.getMinimalDaysInFirstWeek());break;case "D":rawData=date.getDayInYear();break;case "d":rawData=date.getDate();break;case "F":rawData=1+Math.floor((date.getDate()-1)/7);break;case "E":rawData=dayNames[date.getDay()];break;case "a":rawData=(date.getHours()>=12)?"PM":"AM";break;case "H":rawData=date.getHours();break;case "k":rawData=1+date.getHours();break;case "K":rawData=date.getHours()%12;break;case "h":rawData=1+(date.getHours()%12);break;case "m":rawData=date.getMinutes();break;case "s":rawData=date.getSeconds();break;case "S":rawData=date.getMilliseconds();break;case "Z":rawData=date.getTimezoneOffset();break}switch(types[patternLetter]){case TEXT2:formattedString+=formatText(rawData,numberOfLetters,2);break;case TEXT3:formattedString+=formatText(rawData,numberOfLetters,3);break;case NUMBER:formattedString+=formatNumber(rawData,numberOfLetters);break;case YEAR:if(numberOfLetters<=2){var dataString=""+rawData;formattedString+=dataString.substr(2,2)}else{formattedString+=formatNumber(rawData,numberOfLetters)}break;case MONTH:if(numberOfLetters>=3){formattedString+=formatText(monthNames[rawData],numberOfLetters,numberOfLetters)}else{formattedString+=formatNumber(rawData+1,numberOfLetters)}break;case TIMEZONE:var isPositive=(rawData>0);var prefix=isPositive?"-":"+";var absData=Math.abs(rawData);var hours=""+Math.floor(absData/60);hours=padWithZeroes(hours,2);var minutes=""+(absData%60);minutes=padWithZeroes(minutes,2);formattedString+=prefix+hours+minutes;break}}searchString=searchString.substr(result.index+result[0].length)}return formattedString}})();var applicationStartDate=new Date();var uniqueId="log4javascript_"+applicationStartDate.getTime()+"_"+Math.floor(Math.random()*100000000);var emptyFunction=function(){};var newLine="\r\n";log4javascript={};log4javascript.version="1.3.1";function getExceptionStringRep(ex){if(ex){var exStr="Exception: ";if(ex.message){exStr+=ex.message}else if(ex.description){exStr+=ex.description}if(ex.lineNumber){exStr+=" on line number "+ex.lineNumber}if(ex.fileName){exStr+=" in file "+ex.fileName}if(showStackTraces&&ex.stack){exStr+=newLine+"Stack trace:"+newLine+ex.stack}return exStr}return null}function formatObjectExpansion(obj,depth,indentation){var i,output,childDepth,childIndentation,childLines;if((obj instanceof Array)&&depth>0){if(!indentation){indentation=""}output="["+newLine;childDepth=depth-1;childIndentation=indentation+" ";childLines=[];for(i=0;i0){if(!indentation){indentation=""}output=""+"{"+newLine;childDepth=depth-1;childIndentation=indentation+" ";childLines=[];for(i in obj){childLines.push(childIndentation+i+": "+formatObjectExpansion(obj[i],childDepth,childIndentation))}output+=childLines.join(","+newLine)+newLine+indentation+"}";return output}else if(typeof obj=="string"){return obj}else{return obj.toString()}}function escapeNewLines(str){return str.replace(/\r\n|\r|\n/g,"\\r\\n")}function urlEncode(str){return escape(str).replace(/\+/g,"%2B").replace(/"/g, "%22").replace(/'/g, "%27").replace(/\//g, "%2F")}function bool(obj){return Boolean(obj)}function array_remove(arr,val){var index=-1;for(var i=0;i=0){arr.splice(index,1);return true}else{return false}}function extractBooleanFromParam(param,defaultValue){if(isUndefined(param)){return defaultValue}else{return bool(param)}}function extractStringFromParam(param,defaultValue){if(isUndefined(param)){return defaultValue}else{return String(param)}}function extractIntFromParam(param,defaultValue){if(isUndefined(param)){return defaultValue}else{try{var value=parseInt(param,10);return isNaN(value)?defaultValue:value}catch(ex){logLog.warn("Invalid int param "+param,ex);return defaultValue}}}function extractFunctionFromParam(param,defaultValue){if(typeof param=="function"){return param}else{return defaultValue}}var logLog={quietMode:false,setQuietMode:function(quietMode){this.quietMode=bool(quietMode)},numberOfErrors:0,alertAllErrors:false,setAlertAllErrors:function(alertAllErrors){this.alertAllErrors=alertAllErrors},debug:function(message,exception){},warn:function(message,exception){},error:function(message,exception){if(++this.numberOfErrors==1||this.alertAllErrors){if(!this.quietMode){var alertMessage="log4javascript error: "+message;if(exception){alertMessage+=newLine+newLine+"Original error: "+getExceptionStringRep(exception)}alert(alertMessage)}}}};log4javascript.logLog=logLog;var errorListeners=[];log4javascript.addErrorListener=function(listener){if(typeof listener=="function"){errorListeners.push(listener)}else{handleError("addErrorListener: listener supplied was not a function")}};log4javascript.removeErrorListener=function(listener){array_remove(errorListeners,listener)};function handleError(message,exception){logLog.error(message,exception);for(var i=0;i=level.level}};Level.ALL=new Level(Number.MIN_VALUE,"ALL");Level.TRACE=new Level(10000,"TRACE");Level.DEBUG=new Level(20000,"DEBUG");Level.INFO=new Level(30000,"INFO");Level.WARN=new Level(40000,"WARN");Level.ERROR=new Level(50000,"ERROR");Level.FATAL=new Level(60000,"FATAL");Level.OFF=new Level(Number.MAX_VALUE,"OFF");log4javascript.Level=Level;var LoggingEvent=function(logger,timeStamp,level,message,exception){this.logger=logger;this.timeStamp=timeStamp;this.timeStampInSeconds=Math.floor(timeStamp.getTime()/1000);this.level=level;this.message=message;this.exception=exception};LoggingEvent.prototype.getThrowableStrRep=function(){return this.exception?getExceptionStringRep(this.exception):""};log4javascript.LoggingEvent=LoggingEvent;var Layout=function(){};Layout.prototype={defaults:{loggerKey:"logger",timeStampKey:"timestamp",levelKey:"level",messageKey:"message",exceptionKey:"exception",urlKey:"url"},loggerKey:"logger",timeStampKey:"timestamp",levelKey:"level",messageKey:"message",exceptionKey:"exception",urlKey:"url",batchHeader:"",batchFooter:"",batchSeparator:"",format:function(loggingEvent){handleError("Layout.format: layout supplied has no format() method")},ignoresThrowable:function(){handleError("Layout.ignoresThrowable: layout supplied has no ignoresThrowable() method")},getContentType:function(){return "text/plain"},allowBatching:function(){return true},getDataValues:function(loggingEvent){var dataValues=[ [this.loggerKey,loggingEvent.logger.name],[this.timeStampKey,loggingEvent.timeStampInSeconds],[this.levelKey,loggingEvent.level.name],[this.urlKey,window.location.href],[this.messageKey,loggingEvent.message] ];if(loggingEvent.exception){dataValues.push([this.exceptionKey,getExceptionStringRep(loggingEvent.exception)])}if(this.hasCustomFields()){for(var i=0;i0)}};log4javascript.Layout=Layout;var SimpleLayout=function(){this.customFields=[]};SimpleLayout.prototype=new Layout();SimpleLayout.prototype.format=function(loggingEvent){return loggingEvent.level.name+" - "+loggingEvent.message};SimpleLayout.prototype.ignoresThrowable=function(loggingEvent){return true};log4javascript.SimpleLayout=SimpleLayout;var NullLayout=function(){this.customFields=[]};NullLayout.prototype=new Layout();NullLayout.prototype.format=function(loggingEvent){return loggingEvent.message};NullLayout.prototype.ignoresThrowable=function(loggingEvent){return true};log4javascript.NullLayout=NullLayout;var XmlLayout=function(){this.customFields=[]};XmlLayout.prototype=new Layout();XmlLayout.prototype.getContentType=function(){return "text/xml"};XmlLayout.prototype.escapeCdata=function(str){return str.replace(/\]\]>/,"]]>]]>"+newLine+""+newLine;if(this.hasCustomFields()){for(var i=0;i"+newLine}}if(loggingEvent.exception){str+=""+newLine}str+=""+newLine+newLine;return str};XmlLayout.prototype.ignoresThrowable=function(loggingEvent){return false};log4javascript.XmlLayout=XmlLayout;var JsonLayout=function(readable,loggerKey,timeStampKey,levelKey,messageKey,exceptionKey,urlKey){this.readable=bool(readable);this.batchHeader=this.readable?"["+newLine:"[";this.batchFooter=this.readable?"]"+newLine:"]";this.batchSeparator=this.readable?","+newLine:",";this.setKeys(loggerKey,timeStampKey,levelKey,messageKey,exceptionKey,urlKey);this.propertySeparator=this.readable?", ":",";this.colon=this.readable?": ":":";this.customFields=[]};JsonLayout.prototype=new Layout();JsonLayout.prototype.setReadable=function(readable){this.readable=bool(readable)};JsonLayout.prototype.isReadable=function(){return this.readable};JsonLayout.prototype.format=function(loggingEvent){var dataValues=this.getDataValues(loggingEvent);var str="{";if(this.readable){str+=newLine}for(var i=0;i=loggerNameBits.length){replacement=loggerName}else{replacement=loggerNameBits.slice(loggerNameBits.length-precision).join(".")}}else{replacement=loggerName}break;case "d":var dateFormat=PatternLayout.ISO8601_DATEFORMAT;if(specifier){dateFormat=specifier;if(dateFormat=="ISO8601"){dateFormat=PatternLayout.ISO8601_DATEFORMAT}else if(dateFormat=="ABSOLUTE"){dateFormat=PatternLayout.ABSOLUTETIME_DATEFORMAT}else if(dateFormat=="DATE"){dateFormat=PatternLayout.DATETIME_DATEFORMAT}}replacement=(new SimpleDateFormat(dateFormat)).format(loggingEvent.timeStamp);break;case "f":if(this.hasCustomFields()){var fieldIndex=0;if(specifier){fieldIndex=parseInt(specifier,10);if(isNaN(fieldIndex)){handleError("PatternLayout.format: invalid specifier '"+specifier+"' for conversion character 'f' - should be a number")}else if(fieldIndex===0){handleError("PatternLayout.format: invalid specifier '"+specifier+"' for conversion character 'f' - must be greater than zero")}else if(fieldIndex>this.customFields.length){handleError("PatternLayout.format: invalid specifier '"+specifier+"' for conversion character 'f' - there aren't that many custom fields")}else{fieldIndex=fieldIndex-1}}replacement=this.customFields[fieldIndex].value}break;case "m":if(specifier){var depth=parseInt(specifier,10);if(isNaN(depth)){handleError("PatternLayout.format: invalid specifier '"+specifier+"' for conversion character 'm' - should be a number");replacement=loggingEvent.message}else{replacement=formatObjectExpansion(loggingEvent.message,depth)}}else{replacement=loggingEvent.message}break;case "n":replacement=newLine;break;case "p":replacement=loggingEvent.level.name;break;case "r":replacement=""+loggingEvent.timeStamp.getDifference(applicationStartDate);break;case "%":replacement="%";break;default:replacement=matchedString;break}var len;if(truncation){len=parseInt(truncation.substr(1),10);var strLen=replacement.length;if(len=this.threshold.level){this.append(loggingEvent)}},append:function(loggingEvent){},setLayout:function(layout){if(layout instanceof Layout){this.layout=layout}else{handleError("Appender.setLayout: layout supplied to "+this.toString()+" is not a subclass of Layout")}},getLayout:function(){return this.layout},setThreshold:function(threshold){if(threshold instanceof Level){this.threshold=threshold}else{handleError("Appender.setThreshold: threshold supplied to "+this.toString()+" is not a subclass of Level")}},getThreshold:function(){return this.threshold},toString:function(){return "[Base Appender]"}};log4javascript.Appender=Appender;var AlertAppender=function(layout){if(layout){this.setLayout(layout)}};AlertAppender.prototype=new Appender();AlertAppender.prototype.layout=new SimpleLayout();AlertAppender.prototype.append=function(loggingEvent){var formattedMessage=this.getLayout().format(loggingEvent);if(this.getLayout().ignoresThrowable()){formattedMessage+=loggingEvent.getThrowableStrRep()}alert(formattedMessage)};AlertAppender.prototype.toString=function(){return "[AlertAppender]"};log4javascript.AlertAppender=AlertAppender;var AjaxAppender=function(url,layout,timed,waitForResponse,batchSize,timerInterval,requestSuccessCallback,failCallback){var appender=this;var isSupported=true;if(!url){handleError("AjaxAppender: URL must be specified in constructor");isSupported=false}timed=extractBooleanFromParam(timed,this.defaults.timed);waitForResponse=extractBooleanFromParam(waitForResponse,this.defaults.waitForResponse);batchSize=extractIntFromParam(batchSize,this.defaults.batchSize);timerInterval=extractIntFromParam(timerInterval,this.defaults.timerInterval);requestSuccessCallback=extractFunctionFromParam(requestSuccessCallback,this.defaults.requestSuccessCallback);failCallback=extractFunctionFromParam(failCallback,this.defaults.failCallback);var sessionId=null;var queuedLoggingEvents=[];var queuedRequests=[];var sending=false;var initialized=false;function checkCanConfigure(configOptionName){if(initialized){handleError("AjaxAppender: configuration option '"+configOptionName+"' may not be set after the appender has been initialized");return false}return true}this.getSessionId=function(){return sessionId};this.setSessionId=function(sessionIdParam){sessionId=extractStringFromParam(sessionIdParam,null);this.layout.setCustomField("sessionid",sessionId)};this.setLayout=function(layout){if(checkCanConfigure("layout")){this.layout=layout;if(sessionId!==null){this.setSessionId(sessionId)}}};if(layout){this.setLayout(layout)}this.isTimed=function(){return timed};this.setTimed=function(timedParam){if(checkCanConfigure("timed")){timed=bool(timedParam)}};this.getTimerInterval=function(){return timerInterval};this.setTimerInterval=function(timerIntervalParam){if(checkCanConfigure("timerInterval")){timerInterval=extractIntFromParam(timerIntervalParam,timerInterval)}};this.isWaitForResponse=function(){return waitForResponse};this.setWaitForResponse=function(waitForResponseParam){if(checkCanConfigure("waitForResponse")){waitForResponse=bool(waitForResponseParam)}};this.getBatchSize=function(){return batchSize};this.setBatchSize=function(batchSizeParam){if(checkCanConfigure("batchSize")){batchSize=extractIntFromParam(batchSizeParam,batchSize)}};this.setRequestSuccessCallback=function(requestSuccessCallbackParam){requestSuccessCallback=extractFunctionFromParam(requestSuccessCallbackParam,requestSuccessCallback)};this.setFailCallback=function(failCallbackParam){failCallback=extractFunctionFromParam(failCallbackParam,failCallback)};function sendAll(){if(isSupported&&enabled){sending=true;var currentRequestBatch;if(waitForResponse){if(queuedRequests.length>0){currentRequestBatch=queuedRequests.shift();sendRequest(preparePostData(currentRequestBatch),sendAll)}else{sending=false;if(timed){scheduleSending()}}}else{while((currentRequestBatch=queuedRequests.shift())){sendRequest(preparePostData(currentRequestBatch))}sending=false;if(timed){scheduleSending()}}}}this.sendAll=sendAll;function preparePostData(batchedLoggingEvents){var formattedMessages=[];var currentLoggingEvent;var postData="";while((currentLoggingEvent=batchedLoggingEvents.shift())){var currentFormattedMessage=appender.getLayout().format(currentLoggingEvent);if(appender.getLayout().ignoresThrowable()){currentFormattedMessage+=loggingEvent.getThrowableStrRep()}formattedMessages.push(currentFormattedMessage)}if(batchedLoggingEvents.length==1){postData=formattedMessages.join("")}else{postData=appender.getLayout().batchHeader+formattedMessages.join(appender.getLayout().batchSeparator)+appender.getLayout().batchFooter}return postData}function scheduleSending(){setTimeout(sendAll,timerInterval)}function getXmlHttp(){var xmlHttp=null;if(typeof XMLHttpRequest=="object"||typeof XMLHttpRequest=="function"){xmlHttp=new XMLHttpRequest()}else{try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e2){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e3){var msg="AjaxAppender: could not create XMLHttpRequest object. AjaxAppender disabled";handleError(msg);isSupported=false;if(failCallback){failCallback(msg)}}}}return xmlHttp}function sendRequest(postData,successCallback){try{var xmlHttp=getXmlHttp();if(isSupported){if(xmlHttp.overrideMimeType){xmlHttp.overrideMimeType(appender.getLayout().getContentType())}xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){var success=(isUndefined(xmlHttp.status)||xmlHttp.status===0||(xmlHttp.status>=200&&xmlHttp.status<300));if(success){if(requestSuccessCallback){requestSuccessCallback(xmlHttp)}if(successCallback){successCallback(xmlHttp)}}else{var msg="AjaxAppender.append: XMLHttpRequest request to URL "+url+" returned status code "+xmlHttp.status;handleError(msg);if(failCallback){failCallback(msg)}}xmlHttp.onreadystatechange=emptyFunction;xmlHttp=null}};xmlHttp.open("POST",url,true);try{xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}catch(headerEx){var msg="AjaxAppender.append: your browser's XMLHttpRequest implementation"+" does not support setRequestHeader, therefore cannot post data. AjaxAppender disabled";handleError(msg);isSupported=false;if(failCallback){failCallback(msg)}return}xmlHttp.send(postData)}}catch(ex){var msg="AjaxAppender.append: error sending log message to "+url;handleError(msg,ex);if(failCallback){failCallback(msg+". Details: "+getExceptionStringRep(ex))}}}this.append=function(loggingEvent){if(isSupported){if(!initialized){init()}queuedLoggingEvents.push(loggingEvent);var actualBatchSize=this.getLayout().allowBatching()?batchSize:1;if(queuedLoggingEvents.length>=actualBatchSize){var currentLoggingEvent;var postData="";var batchedLoggingEvents=[];while((currentLoggingEvent=queuedLoggingEvents.shift())){batchedLoggingEvents.push(currentLoggingEvent)}queuedRequests.push(batchedLoggingEvents);if(!timed){if(!waitForResponse||(waitForResponse&&!sending)){sendAll()}}}}};function init(){initialized=true;if(timed){scheduleSending()}}};AjaxAppender.prototype=new Appender();AjaxAppender.prototype.defaults={waitForResponse:false,timed:false,timerInterval:1000,batchSize:1,requestSuccessCallback:null,failCallback:null};AjaxAppender.prototype.layout=new HttpPostDataLayout();AjaxAppender.prototype.toString=function(){return "[AjaxAppender]"};log4javascript.AjaxAppender=AjaxAppender;(function(){var getConsoleHtmlLines=function(){return [ '','','','log4javascript','','','','','','
','
','
','Filters:','','','','','','','','
','','
','Options:','','','','','','','
','
','
','
','','' ]};function ConsoleAppender(){}var consoleAppenderIdCounter=1;ConsoleAppender.prototype=new Appender();ConsoleAppender.prototype.create=function(inPage,containerElement,layout,lazyInit,focusConsoleWindow,useOldPopUp,complainAboutPopUpBlocking,newestMessageAtTop,scrollToLatestMessage,initiallyMinimized,width,height,reopenWhenClosed,maxMessages){var appender=this;if(layout){this.setLayout(layout)}else{this.setLayout(this.defaults.layout)}var initialized=false;var consoleWindowLoaded=false;var queuedLoggingEvents=[];var isSupported=true;var consoleAppenderId=consoleAppenderIdCounter++;lazyInit=extractBooleanFromParam(lazyInit,true);newestMessageAtTop=extractBooleanFromParam(newestMessageAtTop,this.defaults.newestMessageAtTop);scrollToLatestMessage=extractBooleanFromParam(scrollToLatestMessage,this.defaults.scrollToLatestMessage);width=width?width:this.defaults.width;height=height?height:this.defaults.height;maxMessages=maxMessages?maxMessages:this.defaults.maxMessages;var init,safeToAppend,getConsoleWindow;var appenderName=inPage?"InPageAppender":"PopUpAppender";var checkCanConfigure=function(configOptionName){if(initialized){handleError(appenderName+": configuration option '"+configOptionName+"' may not be set after the appender has been initialized");return false}return true};this.isNewestMessageAtTop=function(){return newestMessageAtTop};this.setNewestMessageAtTop=function(newestMessageAtTopParam){newestMessageAtTop=bool(newestMessageAtTopParam);if(consoleWindowLoaded&&isSupported){getConsoleWindow().setNewestAtTop(newestMessageAtTop)}};this.isScrollToLatestMessage=function(){return scrollToLatestMessage};this.setScrollToLatestMessage=function(scrollToLatestMessageParam){scrollToLatestMessage=bool(scrollToLatestMessageParam);if(consoleWindowLoaded&&isSupported){getConsoleWindow().setScrollToLatest(scrollToLatestMessage)}};this.getWidth=function(){return width};this.setWidth=function(widthParam){if(checkCanConfigure("width")){width=extractStringFromParam(widthParam,width)}};this.getHeight=function(){return height};this.setHeight=function(heightParam){if(checkCanConfigure("height")){height=extractStringFromParam(heightParam,height)}};this.getMaxMessages=function(){return maxMessages};this.setMaxMessages=function(maxMessagesParam){maxMessages=extractIntFromParam(maxMessagesParam,maxMessages);if(consoleWindowLoaded&&isSupported){getConsoleWindow().setMaxMessages(maxMessages)}};this.append=function(loggingEvent){if(isSupported){queuedLoggingEvents.push(loggingEvent);var isSafeToAppend=safeToAppend();if(!initialized||(consoleClosed&&reopenWhenClosed)){init()}if(safeToAppend()){appendQueuedLoggingEvents()}}};var appendQueuedLoggingEvents=function(loggingEvent){while(queuedLoggingEvents.length>0){var currentLoggingEvent=queuedLoggingEvents.shift();var formattedMessage=appender.getLayout().format(currentLoggingEvent);if(appender.getLayout().ignoresThrowable()){formattedMessage+=currentLoggingEvent.getThrowableStrRep()}getConsoleWindow().log(currentLoggingEvent.level,formattedMessage)}if(focusConsoleWindow){getConsoleWindow().focus()}};var writeHtml=function(doc){var lines=getConsoleHtmlLines();doc.open();for(var i=0;i";iframeContainerDiv.innerHTML=iframeHtml;consoleClosed=false;var iframeDocumentExistsTest=function(win){return bool(win)&&bool(win.document)};if(iframeDocumentExistsTest(getConsoleWindow())){writeToDocument()}else{pollConsoleWindow(iframeDocumentExistsTest,writeToDocument,initErrorMessage)}initialized=true};getConsoleWindow=function(){var iframe=window.frames[iframeId];if(iframe){return iframe}};safeToAppend=function(){if(isSupported&&!consoleClosed){if(!consoleWindowLoaded&&getConsoleWindow()&&getConsoleWindow().loaded){consoleWindowLoaded=true}return consoleWindowLoaded}return false}}else{useOldPopUp=extractBooleanFromParam(useOldPopUp,appender.defaults.useOldPopUp);complainAboutPopUpBlocking=extractBooleanFromParam(complainAboutPopUpBlocking,appender.defaults.complainAboutPopUpBlocking);reopenWhenClosed=extractBooleanFromParam(reopenWhenClosed,this.defaults.reopenWhenClosed);this.isUseOldPopUp=function(){return useOldPopUp};this.setUseOldPopUp=function(useOldPopUpParam){if(checkCanConfigure("useOldPopUp")){useOldPopUp=bool(useOldPopUpParam)}};this.isComplainAboutPopUpBlocking=function(){return complainAboutPopUpBlocking};this.setComplainAboutPopUpBlocking=function(complainAboutPopUpBlockingParam){if(checkCanConfigure("complainAboutPopUpBlocking")){complainAboutPopUpBlocking=bool(complainAboutPopUpBlockingParam)}};this.isFocusPopUp=function(){return focusConsoleWindow};this.setFocusPopUp=function(focusPopUpParam){focusConsoleWindow=bool(focusPopUpParam)};this.isReopenWhenClosed=function(){return reopenWhenClosed};this.setReopenWhenClosed=function(reopenWhenClosedParam){reopenWhenClosed=bool(reopenWhenClosedParam)};this.close=function(){try{popUp.close()}catch(e){}consoleClosed=true};var popUp;init=function(){var windowProperties="width="+width+",height="+height+",status,resizable";var windowName="PopUp_"+location.host.replace(/[^a-z0-9]/gi,"_")+"_"+consoleAppenderId;if(!useOldPopUp){windowName=windowName+"_"+uniqueId}function finalInit(){consoleWindowLoaded=true;getConsoleWindow().setNewestAtTop(newestMessageAtTop);getConsoleWindow().setScrollToLatest(scrollToLatestMessage);getConsoleWindow().setMaxMessages(maxMessages);appendQueuedLoggingEvents()}try{popUp=window.open("",windowName,windowProperties);consoleClosed=false;if(popUp){if(useOldPopUp&&popUp.loaded){popUp.mainPageReloaded();finalInit()}else{writeHtml(popUp.document);var popUpLoadedTest=function(win){return bool(win)&&win.loaded};if(popUp.loaded){finalInit()}else{pollConsoleWindow(popUpLoadedTest,finalInit,"PopUpAppender.init: unable to create console window")}}}else{isSupported=false;logLog.warn("PopUpAppender.init: pop-ups blocked, please unblock to use PopUpAppender");if(complainAboutPopUpBlocking){handleError("log4javascript: pop-up windows appear to be blocked. Please unblock them to use pop-up logging.")}}}catch(ex){handleError("PopUpAppender.init: error creating pop-up",ex)}initialized=true};getConsoleWindow=function(){return popUp};safeToAppend=function(){if(isSupported&&!isUndefined(popUp)&&!consoleClosed){if(popUp.closed||(consoleWindowLoaded&&isUndefined(popUp.closed))){consoleClosed=true;logLog.debug("PopUpAppender: pop-up closed");return false}if(!consoleWindowLoaded&&popUp.loaded){consoleWindowLoaded=true}}return isSupported&&consoleWindowLoaded&&!consoleClosed}}if(enabled&&!lazyInit){init()}this.getConsoleWindow=getConsoleWindow};var PopUpAppender=function(lazyInit,layout,focusPopUp,useOldPopUp,complainAboutPopUpBlocking,newestMessageAtTop,scrollToLatestMessage,reopenWhenClosed,width,height,maxMessages){var focusConsoleWindow=extractBooleanFromParam(focusPopUp,this.defaults.focusPopUp);this.create(false,null,layout,lazyInit,focusConsoleWindow,useOldPopUp,complainAboutPopUpBlocking,newestMessageAtTop,scrollToLatestMessage,null,width,height,reopenWhenClosed,maxMessages)};PopUpAppender.prototype=new ConsoleAppender();PopUpAppender.prototype.defaults={layout:new PatternLayout("%d{HH:mm:ss} %-5p - %m{1}%n"),focusPopUp:false,lazyInit:true,useOldPopUp:true,complainAboutPopUpBlocking:true,newestMessageAtTop:false,scrollToLatestMessage:true,width:"600",height:"400",reopenWhenClosed:false,maxMessages:null};PopUpAppender.prototype.toString=function(){return "[PopUpAppender]"};log4javascript.PopUpAppender=PopUpAppender;var InPageAppender=function(containerElement,lazyInit,layout,initiallyMinimized,newestMessageAtTop,scrollToLatestMessage,width,height,maxMessages){this.create(true,containerElement,layout,lazyInit,false,null,null,newestMessageAtTop,scrollToLatestMessage,initiallyMinimized,width,height,null,maxMessages)};InPageAppender.prototype=new ConsoleAppender();InPageAppender.prototype.defaults={layout:new PatternLayout("%d{HH:mm:ss} %-5p - %m{1}%n"),initiallyMinimized:false,lazyInit:true,newestMessageAtTop:false,scrollToLatestMessage:true,width:"100%",height:"250px",maxMessages:null};InPageAppender.prototype.toString=function(){return "[InPageAppender]"};log4javascript.InPageAppender=InPageAppender;log4javascript.InlineAppender=InPageAppender})();var BrowserConsoleAppender=function(layout){if(layout){this.setLayout(layout)}};BrowserConsoleAppender.prototype=new log4javascript.Appender();BrowserConsoleAppender.prototype.layout=new NullLayout();BrowserConsoleAppender.prototype.threshold=Level.DEBUG;BrowserConsoleAppender.prototype.append=function(loggingEvent){var appender=this;var getFormattedMessage=function(){var layout=appender.getLayout();var formattedMessage=layout.format(loggingEvent);if(layout.ignoresThrowable()&&loggingEvent.exception){formattedMessage+=loggingEvent.getThrowableStrRep()}return formattedMessage};if((typeof opera!="undefined")&&opera.postError){opera.postError(getFormattedMessage())}else if(window.console&&window.console.log){var formattedMesage=getFormattedMessage();if(window.console.debug&&Level.DEBUG.isGreaterOrEqual(loggingEvent.level)){window.console.debug(formattedMesage)}else if(window.console.info&&Level.INFO.equals(loggingEvent.level)){window.console.info(formattedMesage)}else if(window.console.warn&&Level.WARN.equals(loggingEvent.level)){window.console.warn(formattedMesage)}else if(window.console.error&&loggingEvent.level.isGreaterOrEqual(Level.ERROR)){window.console.error(formattedMesage)}else{window.console.log(formattedMesage)}}};BrowserConsoleAppender.prototype.toString=function(){return "[BrowserConsoleAppender]"};log4javascript.BrowserConsoleAppender=BrowserConsoleAppender})();