loggingTest
Shell of logging snippet with wcl(), wce(), wci(), wcw, wct() ffunctions
by spmbt
HTML
Show log panel and change serttings:<br>
logOnScreen =0 //0|1<br>
,logLevel =0 //0..4<br>
,logTime =1 //0|1<br>
,noConsole =0
JavaScript
var IE = !!document.all
$x = function(el, h){if(h) for(var i in h) el[i] = h[i]; return el},
$e = function(g){//g={el,cl,ht,cs,at,atRemove,on,revent,ap,apT,prT,bef,aft,f+fA}
if(!g.el && g.el !==undefined && g.el !='') return g.el;
g.el = g.el ||'DIV';
var o = g.el = typeof g.el =='string'? document.createElement(g.el) : g.el;
if(o){
if(g.cl)
o.className = g.cl;
if(g.cs){
if(!IE) $x(o.style, g.cs);
else{
var s ='';
for(i in g.cs)
s += toCsKey(i) +':'+ g.cs[i] +';';
o.style.cssText = s;
}}
if(g.ht || g.at){
var at = g.at ||{}; if(g.ht) at.innerHTML = g.ht;}
if(at)
for(var i in at){
if(i=='innerHTML') o[i] = at[i];
else o.setAttribute(i, at[i]);}
if(g.on)
for(var i in g.on) if(g.on[i])
o[['addEventListener','attachEvent'][+IE]](['','on'][+IE]+i, g.on[i],!1);
g.apT && g.apT.appendChild(o); //ставится по ориентации, если новый
}
return o;
},
noConsole =0
,win = window
,wcl0 = function(a){ a = a!==undefined ? a :''; //консоль как метод строки или функция, с откл. по noConsole ==1, +IE
if(win.console && noConsole !==undefined)
Function.prototype.apply.call(console.log, console, this instanceof String
? ["'=="+ this +"'"].concat([].slice.call(arguments))
: arguments);
};
String.prototype.wcl0 = wcl0;
/*(function(w, logLevel, wcA){ var lvl =0;
for(var i in wcA) //консоль[i] как метод строки или функция
w[i] = (function(lvl, wcAI, i){
return function(a){ a = a!==undefined|| arguments.length ? a :'';
if(w.console && logLevel <= lvl)
Function.prototype.apply.call(w.console[i], w.console, this instanceof String
//w.console[i].apply(console, this instanceof String //--for without IE
? [wcAI + this +"'"].concat([].slice.call(arguments))
: arguments);
else
w.console[i] = function(){};
} })(lvl++, wcA[i], {wcw:'warn', wci:'info', wcl:'log',...