[Mod]Close #540,实现LogEngine的单例模式

This commit is contained in:
vn.py 2017-10-18 10:38:41 +08:00
parent 2406d4a586
commit 84e6eb277f

View File

@ -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):