python处理nginx日志,并统计分析---我这个写的处理时间效率不高,有好方法,请大家指正
2016-05-08 13:22
1116 查看
自从学习ext以来就一直感觉很混乱,特别是 this啊 var啊 类和函数的区别啊.感觉都是差不多的东西.今天在网上搜搜了一整天 整理了一点.
this和var 的文章已经发过了,这里只是讨论继承.
1.继承,子类调用父类的构造函数
SubClass.spuperclass.constructor.call(this,config || {});
注意:SubClass要注册supperclass属性,SubClass.superclass=SupperClass.prototype;
另外Ext还增加原型的supclass属性,使用闭包,改变this的作用域,在Ext.extend中
sb.superclass=spp;
sbp.superclass = sbp.supr = (function(){
return spp;
});
则this.superclass().getXX.apply(this);
Ext的继承:
(1)没有指定子类,其prototype属性的constructor为调用父类的构造函数
源码:sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
var myclass=Ext.extend(supclass,{/*一些增加的方法*/})
(2)指定constructor函数来完成子类的构造器
var myclass=Ext.extend(supclass,{constructor:function(){/*构建子类*/},/*一些增加的方法*/})
(3)子类采用自身的构建函数
var myclass=function(config)
{
myclass.superclass.constructor.call(this,this.meta);//把参数传给父类的构建器
/*其他相关处理*/
}
Ext.extend(myclass,supclass,{*一些增加的方法});
2.注册,监听,执行事件
this.addEvents('nodeClick');//在构造函数内,addEvents是Ext方法
this.initTreeEvent();//监听方法,。。自我实现
this.fireEvent('nodeClick',node.attributes);
addEvents : function(o){
var me = this;
me.events = me.events || {};
if (typeof o == 'string') {
var a = arguments,
i = a.length;
while(i--) {
me.events[a[i]] = me.events[a[i]] || TRUE;
}
} else {
Ext.applyIf(me.events, o);
}
},
fireEvent : function(){
var a = Array.prototype.slice.call(arguments, 0),
ename = a[0].toLowerCase(),
me = this,
ret = TRUE,
ce = me.events[ename],
cc,
q,
c;
if (me.eventsSuspended === TRUE) {
if (q = me.eventQueue) {
q.push(a);
}
}
else if(typeof ce == 'object') {
if (ce.bubble){
if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
return FALSE;
}
c = me.getBubbleTarget && me.getBubbleTarget();
if(c && c.enableBubble) {
cc = c.events[ename];
if(!cc || typeof cc != 'object' || !cc.bubble) {
c.enableBubble(ename);
}
return c.fireEvent.apply(c, a);
}
}
else {
a.shift();
ret = ce.fire.apply(ce, a);
}
}
return ret;
},
addListener : function(eventName, fn, scope, o){
var me = this,
e,
oe,
isF,
ce;
if (typeof eventName == 'object') {
o = eventName;
for (e in o){
oe = o[e];
if (!me.filterOptRe.test(e)) {
me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o);
}
}
} else {
eventName = eventName.toLowerCase();
ce = me.events[eventName] || TRUE;
if (typeof ce == 'boolean') {
me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
}
ce.addListener(fn, scope, typeof o == 'object' ? o : {});
}
},
removeListener : function(eventName, fn, scope){
var ce = this.events[eventName.toLowerCase()];
if (typeof ce == 'object') {
ce.removeListener(fn, scope);
}
},
3.闭包
内层函数用到外层的变量,并且外层变量不会回收,而且其他地方访问不到id变量
uniqueID=(function(){
var id=0;
return function(){return id++};
})();
4.stirng,
使用String类的方法
this和var 的文章已经发过了,这里只是讨论继承.
1.继承,子类调用父类的构造函数
SubClass.spuperclass.constructor.call(this,config || {});
注意:SubClass要注册supperclass属性,SubClass.superclass=SupperClass.prototype;
另外Ext还增加原型的supclass属性,使用闭包,改变this的作用域,在Ext.extend中
sb.superclass=spp;
sbp.superclass = sbp.supr = (function(){
return spp;
});
则this.superclass().getXX.apply(this);
Ext的继承:
(1)没有指定子类,其prototype属性的constructor为调用父类的构造函数
源码:sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
var myclass=Ext.extend(supclass,{/*一些增加的方法*/})
(2)指定constructor函数来完成子类的构造器
var myclass=Ext.extend(supclass,{constructor:function(){/*构建子类*/},/*一些增加的方法*/})
(3)子类采用自身的构建函数
var myclass=function(config)
{
myclass.superclass.constructor.call(this,this.meta);//把参数传给父类的构建器
/*其他相关处理*/
}
Ext.extend(myclass,supclass,{*一些增加的方法});
2.注册,监听,执行事件
this.addEvents('nodeClick');//在构造函数内,addEvents是Ext方法
this.initTreeEvent();//监听方法,。。自我实现
this.fireEvent('nodeClick',node.attributes);
addEvents : function(o){
var me = this;
me.events = me.events || {};
if (typeof o == 'string') {
var a = arguments,
i = a.length;
while(i--) {
me.events[a[i]] = me.events[a[i]] || TRUE;
}
} else {
Ext.applyIf(me.events, o);
}
},
fireEvent : function(){
var a = Array.prototype.slice.call(arguments, 0),
ename = a[0].toLowerCase(),
me = this,
ret = TRUE,
ce = me.events[ename],
cc,
q,
c;
if (me.eventsSuspended === TRUE) {
if (q = me.eventQueue) {
q.push(a);
}
}
else if(typeof ce == 'object') {
if (ce.bubble){
if(ce.fire.apply(ce, a.slice(1)) === FALSE) {
return FALSE;
}
c = me.getBubbleTarget && me.getBubbleTarget();
if(c && c.enableBubble) {
cc = c.events[ename];
if(!cc || typeof cc != 'object' || !cc.bubble) {
c.enableBubble(ename);
}
return c.fireEvent.apply(c, a);
}
}
else {
a.shift();
ret = ce.fire.apply(ce, a);
}
}
return ret;
},
addListener : function(eventName, fn, scope, o){
var me = this,
e,
oe,
isF,
ce;
if (typeof eventName == 'object') {
o = eventName;
for (e in o){
oe = o[e];
if (!me.filterOptRe.test(e)) {
me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o);
}
}
} else {
eventName = eventName.toLowerCase();
ce = me.events[eventName] || TRUE;
if (typeof ce == 'boolean') {
me.events[eventName] = ce = new EXTUTIL.Event(me, eventName);
}
ce.addListener(fn, scope, typeof o == 'object' ? o : {});
}
},
removeListener : function(eventName, fn, scope){
var ce = this.events[eventName.toLowerCase()];
if (typeof ce == 'object') {
ce.removeListener(fn, scope);
}
},
3.闭包
内层函数用到外层的变量,并且外层变量不会回收,而且其他地方访问不到id变量
uniqueID=(function(){
var id=0;
return function(){return id++};
})();
4.stirng,
使用String类的方法
var i, len,dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,
相关文章推荐
- zabbix监控Nginx
- Nginx 虚拟主机 VirtualHost 配置
- nginx日志文件切割
- nginx启动脚本
- nginx
- nginx的启动与关闭
- Nginx搭建负载环境
- /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1
- @CentOS下安装Nginx
- 03-nginx负载均衡
- nginx-rtmp-module安装笔记
- ngxtop nginx 日志实时分析
- Nginx 之五: Nginx服务器的负载均衡、缓存与动静分离功能
- nginx+uwsgi安装出错
- Linux:centOS 7安装nginx
- CentOS下安装Nginx
- nginx.conf
- 在容器中部署静态网站----Nginx
- Nginx的安装以及配置
- Apache与Nginx的优缺点比较