diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index 495cc435..598e8bb1 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -518,6 +518,16 @@ class LogEngine(object): 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):