Merge pull request #644 from mhxueshan/dev
vtEngine.py中LogEngine单例模式变更, ctaEngine.py中saveSyncData函数中字符串格式变更
This commit is contained in:
commit
2d09a42ca4
@ -590,7 +590,7 @@ class CtaEngine(object):
|
||||
self.mainEngine.dbUpdate(POSITION_DB_NAME, strategy.className,
|
||||
d, flt, True)
|
||||
|
||||
content = '策略%s同步数据保存成功,当前持仓%s' %(strategy.name, strategy.pos)
|
||||
content = u'策略%s同步数据保存成功,当前持仓%s' %(strategy.name, strategy.pos)
|
||||
self.writeCtaLog(content)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -535,25 +535,31 @@ class DataEngine(object):
|
||||
|
||||
|
||||
########################################################################
|
||||
class Singleton(type):
|
||||
"""
|
||||
单例,应用方式:静态变量 __metaclass__ = Singleton
|
||||
"""
|
||||
def __init__(cls, name, bases, dict):
|
||||
super(Singleton, cls).__init__(name, bases, dict)
|
||||
cls._instance = None
|
||||
|
||||
def __call__(cls, *args, **kw):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(Singleton, cls).__call__(*args, **kw)
|
||||
return cls._instance
|
||||
|
||||
class LogEngine(object):
|
||||
"""日志引擎"""
|
||||
|
||||
# 单例模式
|
||||
__metaclass__ = Singleton
|
||||
|
||||
# 日志级别
|
||||
LEVEL_DEBUG = logging.DEBUG
|
||||
LEVEL_INFO = logging.INFO
|
||||
LEVEL_WARN = logging.WARN
|
||||
LEVEL_ERROR = logging.ERROR
|
||||
LEVEL_CRITICAL = logging.CRITICAL
|
||||
|
||||
# 单例对象
|
||||
instance = None
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""创建对象,保证单例"""
|
||||
if not cls.instance:
|
||||
cls.instance = super(LogEngine, cls).__new__(cls, *args, **kwargs)
|
||||
return cls.instance
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user