XNginxLog.py 注意:Python2 父类 XNginxLog(object) 必须要加object
import datetime, timeimport urlparseimport reclass XNginxLog(object): """ """ __IP = r"?P[\d.]*" __DATE = r"?P \d+" __MONTH = r"?P \w+" __YEAR = r"?P \d+" __LOG_TIME = r"?P
XAdNginxLog.py
from common import XNginxLogclass XAdNginxLog(XNginxLog): def __init__(self, p_line=None): #super(XAdNginxLog., self).__init__(p_line) super(XAdNginxLog, self).__init__(p_line) self.abc = 1 def has_the_same_device_id(self, p_nginx_log=None): v = self.get_query_dict().get('device_id') is not None and self.get_query_dict().get('device_id') == p_nginx_log.get_query_dict().get( 'device_id') return v def has_the_same_request_id(self, p_nginx_log=None): v = self.get_query_dict().get('request_id') is not None and self.get_query_dict().get('request_id') == p_nginx_log.get_query_dict().get( 'request_id') return v def is_xad_request(self): v = self.get_query_dict().get('channel_name', None) is not None and self.get_query_dict().get('version', None) is not None return v def is_xad_tracking(self): event_type = self.get_query_dict().get('event_type', None) v = event_type is not None and event_type.find('xad_') >= 0 return v
使用
log_obj = XAdNginxLog(p_line=line)