diff --git a/vnpy/trader/app/ctaStrategy/ctaEngine.py b/vnpy/trader/app/ctaStrategy/ctaEngine.py index bcce81c1..0fdf5bbe 100644 --- a/vnpy/trader/app/ctaStrategy/ctaEngine.py +++ b/vnpy/trader/app/ctaStrategy/ctaEngine.py @@ -80,6 +80,9 @@ class CtaEngine(object): # 引擎类型为实盘 self.engineType = ENGINETYPE_TRADING + # 注册日式事件类型 + self.mainEngine.registerLogEvent(EVENT_CTA_LOG) + # 注册事件监听 self.registerEvent() @@ -335,6 +338,7 @@ class CtaEngine(object): """快速发出CTA模块日志事件""" log = VtLogData() log.logContent = content + log.gatewayName = 'CTA_STRATEGY' event = Event(type_=EVENT_CTA_LOG) event.dict_['data'] = log self.eventEngine.put(event) diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index 1e1dffc1..a7e21433 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -185,6 +185,7 @@ class MainEngine(object): """快速发出日志事件""" log = VtLogData() log.logContent = content + log.gatewayName = 'MAIN_ENGINE' event = Event(type_=EVENT_LOG) event.dict_['data'] = log self.eventEngine.put(event) @@ -324,7 +325,12 @@ class MainEngine(object): self.logEngine.addFileHandler() # 注册事件监听 - self.eventEngine.register(EVENT_LOG, self.logEngine.processLogEvent) + self.registerLogEvent(EVENT_LOG) + + #---------------------------------------------------------------------- + def registerLogEvent(self, eventType): + """注册日志事件监听""" + self.eventEngine.register(eventType, self.logEngine.processLogEvent) #---------------------------------------------------------------------- def convertOrderReq(self, req): @@ -593,7 +599,8 @@ class LogEngine(object): """处理日志事件""" log = event.dict_['data'] function = self.levelFunctionDict[log.logLevel] # 获取日志级别对应的处理函数 - function(log.logContent) + msg = '\t'.join([log.gatewayName, log.logContent]) + function(msg) ########################################################################