/* Packed
 *
 * libs/mochikit/Logging.js
 *
 */
if(typeof (dojo)!="undefined"){
dojo.provide("MochiKit.Logging");
dojo.require("MochiKit.Base");
}
if(typeof (JSAN)!="undefined"){
JSAN.use("MochiKit.Base",[]);
}
try{
if(typeof (MochiKit.Base)=="undefined"){
throw "";
}
}
catch(e){
throw "MochiKit.Logging depends on MochiKit.Base!";
}
if(typeof (MochiKit.Logging)=="undefined"){
MochiKit.Logging={};
}
MochiKit.Logging.NAME="MochiKit.Logging";
MochiKit.Logging.VERSION="1.4";
MochiKit.Logging.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Logging.toString=function(){
return this.__repr__();
};
MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"];
MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"];
MochiKit.Logging.LogMessage=function(_1,_2,_3){
this.num=_1;
this.level=_2;
this.info=_3;
this.timestamp=new Date();
};
MochiKit.Logging.LogMessage.prototype={repr:function(){
var m=MochiKit.Base;
return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")";
},toString:MochiKit.Base.forwardCall("repr")};
MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_5){
var _6=MochiKit.Logging;
if(typeof (_5)=="string"){
_5=_6.LogLevel[_5];
}
return function(_7){
var _8=_7.level;
if(typeof (_8)=="string"){
_8=_6.LogLevel[_8];
}
return _8>=_5;
};
},isLogMessage:function(){
var _9=MochiKit.Logging.LogMessage;
for(var i=0;i<arguments.length;i++){
if(!(arguments[i] instanceof _9)){
return false;
}
}
return true;
},compareLogMessage:function(a,b){
return MochiKit.Base.compare([a.level,a.info],[b.level,b.info]);
},alertListener:function(_d){
alert("num: "+_d.num+"\nlevel: "+_d.level+"\ninfo: "+_d.info.join(" "));
}});
MochiKit.Logging.Logger=function(_e){
this.counter=0;
if(typeof (_e)=="undefined"||_e===null){
_e=-1;
}
this.maxSize=_e;
this._messages=[];
this.listeners={};
this.useNativeConsole=false;
};
MochiKit.Logging.Logger.prototype={clear:function(){
this._messages.splice(0,this._messages.length);
},logToConsole:function(_f){
if(typeof (window)!="undefined"&&window.console&&window.console.log){
window.console.log(_f.replace(/%/g,"\uff05"));
}else{
if(typeof (opera)!="undefined"&&opera.postError){
opera.postError(_f);
}else{
if(typeof (printfire)=="function"){
printfire(_f);
}else{
if(typeof (Debug)!="undefined"&&Debug.writeln){
Debug.writeln(_f);
}else{
if(typeof (debug)!="undefined"&&debug.trace){
debug.trace(_f);
}
}
}
}
}
},dispatchListeners:function(msg){
for(var k in this.listeners){
var _12=this.listeners[k];
if(_12.ident!=k||(_12[0]&&!_12[0](msg))){
continue;
}
_12[1](msg);
}
},addListener:function(_13,_14,_15){
if(typeof (_14)=="string"){
_14=MochiKit.Logging.logLevelAtLeast(_14);
}
var _16=[_14,_15];
_16.ident=_13;
this.listeners[_13]=_16;
},removeListener:function(_17){
delete this.listeners[_17];
},baseLog:function(_18,_19){
var msg=new MochiKit.Logging.LogMessage(this.counter,_18,MochiKit.Base.extend(null,arguments,1));
this._messages.push(msg);
this.dispatchListeners(msg);
if(this.useNativeConsole){
this.logToConsole(msg.level+": "+msg.info.join(" "));
}
this.counter+=1;
while(this.maxSize>=0&&this._messages.length>this.maxSize){
this._messages.shift();
}
},getMessages:function(_1b){
var _1c=0;
if(!(typeof (_1b)=="undefined"||_1b===null)){
_1c=Math.max(0,this._messages.length-_1b);
}
return this._messages.slice(_1c);
},getMessageText:function(_1d){
if(typeof (_1d)=="undefined"||_1d===null){
_1d=30;
}
var _1e=this.getMessages(_1d);
if(_1e.length){
var lst=map(function(m){
return "\n  ["+m.num+"] "+m.level+": "+m.info.join(" ");
},_1e);
lst.unshift("LAST "+_1e.length+" MESSAGES:");
return lst.join("");
}
return "";
},debuggingBookmarklet:function(_21){
if(typeof (MochiKit.LoggingPane)=="undefined"){
alert(this.getMessageText());
}else{
MochiKit.LoggingPane.createLoggingPane(_21||false);
}
}};
MochiKit.Logging.__new__=function(){
this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10};
var m=MochiKit.Base;
m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage);
var _23=m.partial;
var _24=this.Logger;
var _25=_24.prototype.baseLog;
m.update(this.Logger.prototype,{debug:_23(_25,"DEBUG"),log:_23(_25,"INFO"),error:_23(_25,"ERROR"),fatal:_23(_25,"FATAL"),warning:_23(_25,"WARNING")});
var _26=this;
var _27=function(_28){
return function(){
_26.logger[_28].apply(_26.logger,arguments);
};
};
this.log=_27("log");
this.logError=_27("error");
this.logDebug=_27("debug");
this.logFatal=_27("fatal");
this.logWarning=_27("warning");
this.logger=new _24();
this.logger.useNativeConsole=true;
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
};
if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){
printfire=function(){
printfire.args=arguments;
var ev=document.createEvent("Events");
ev.initEvent("printfire",false,true);
dispatchEvent(ev);
};
}
MochiKit.Logging.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Logging);



