From 2075fe9866ca86bb4a7f446519142c9595109aef Mon Sep 17 00:00:00 2001 From: msincenselee Date: Wed, 13 Jul 2016 23:42:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BA=A4=E6=98=93=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/vtEngine.py | 13 +++++++++---- vn.trader/vtGateway.py | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/vn.trader/vtEngine.py b/vn.trader/vtEngine.py index 21e057d9..c05ef5a2 100644 --- a/vn.trader/vtEngine.py +++ b/vn.trader/vtEngine.py @@ -14,6 +14,7 @@ from ctaAlgo.ctaEngine import CtaEngine from dataRecorder.drEngine import DrEngine from riskManager.rmEngine import RmEngine +import logging ######################################################################## class MainEngine(object): @@ -62,7 +63,8 @@ class MainEngine(object): self.gatewayDict['CTP_EBF'].setQryEnabled(True) except Exception, e: print e - + + """ try: from ltsGateway.ltsGateway import LtsGateway self.addGateway(LtsGateway, 'LTS') @@ -123,7 +125,7 @@ class MainEngine(object): self.gatewayDict['OANDA'].setQryEnabled(True) except Exception, e: print e - + """ # ---------------------------------------------------------------------- def addGateway(self, gateway, gatewayName=None): """创建接口""" @@ -207,8 +209,11 @@ class MainEngine(object): log.logContent = content event = Event(type_=EVENT_LOG) event.dict_['data'] = log - self.eventEngine.put(event) - + self.eventEngine.put(event) + + # 写入本地log日志 + logging.info(content) + # ---------------------------------------------------------------------- def dbConnect(self): """连接MongoDB数据库""" diff --git a/vn.trader/vtGateway.py b/vn.trader/vtGateway.py index 39d7b740..e11dd20c 100644 --- a/vn.trader/vtGateway.py +++ b/vn.trader/vtGateway.py @@ -92,7 +92,11 @@ class VtGateway(object): # 通用事件 event1 = Event(type_=EVENT_ERROR) event1.dict_['data'] = error - self.eventEngine.put(event1) + self.eventEngine.put(event1) + + logMsg = u'{0}:[{1}]:{2}'.format(error.gatewayName, error.errorID,error.errorMsg ) + # 写入本地log日志 + logging.info(logMsg) # ---------------------------------------------------------------------- def onLog(self, log): @@ -102,7 +106,7 @@ class VtGateway(object): event1.dict_['data'] = log self.eventEngine.put(event1) - # 写入本地log日志 + # 写入本地log日志 logging.info(log.logContent)