当前位置: 首页>>代码示例>>Python>>正文


Python Singleton.getLogFileInstance方法代码示例

本文整理汇总了Python中DPH_Singleton.Singleton.getLogFileInstance方法的典型用法代码示例。如果您正苦于以下问题:Python Singleton.getLogFileInstance方法的具体用法?Python Singleton.getLogFileInstance怎么用?Python Singleton.getLogFileInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DPH_Singleton.Singleton的用法示例。


在下文中一共展示了Singleton.getLogFileInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: writeToLog

# 需要导入模块: from DPH_Singleton import Singleton [as 别名]
# 或者: from DPH_Singleton.Singleton import getLogFileInstance [as 别名]
def writeToLog(dmode, out):
	"""
	singleton handler for the log file
	
	@param dmode: E, W, S, H, A, C, I
	@param out: message string
	@return: none
	"""
	if config.plugins.dreamplex.writeDebugFile.value:
		try:
			instance = Singleton()
			if instance.getLogFileInstance() is "":
				openLogFile()
				gLogFile = instance.getLogFileInstance()
				gLogFile.truncate()
			else:
				gLogFile = instance.getLogFileInstance()

			now = datetime.datetime.now()
			gLogFile.write("%02d:%02d:%02d.%07d " % (now.hour, now.minute, now.second, now.microsecond) + " >>> " + str(
				dmode) + " <<<  " + str(out) + "\n")
			gLogFile.flush()

		except Exception, ex:
			config.plugins.dreamplex.writeDebugFile.value = False
			config.plugins.dreamplex.debugMode.save()

			printl2("Exception(" + str(type(ex)) + "): " + str(ex), "__common__::writeToLog", "E")
开发者ID:DonDavici,项目名称:DreamPlex,代码行数:30,代码来源:__common__.py

示例2: writeToLog

# 需要导入模块: from DPH_Singleton import Singleton [as 别名]
# 或者: from DPH_Singleton.Singleton import getLogFileInstance [as 别名]
def writeToLog(dmode, out):
    """
	singleton handler for the log file
	
	@param dmode: E, W, S, H, A, C, I
	@param out: message string
	@return: none
	"""
    try:
        # =======================================================================
        # if gLogFile is None:
        # 	openLogFile()
        # =======================================================================
        instance = Singleton()
        if instance.getLogFileInstance() is "":
            openLogFile()
            gLogFile = instance.getLogFileInstance()
            gLogFile.truncate()
        else:
            gLogFile = instance.getLogFileInstance()

        now = datetime.datetime.now()
        gLogFile.write(
            "%02d:%02d:%02d.%07d " % (now.hour, now.minute, now.second, now.microsecond)
            + " >>> "
            + str(dmode)
            + " <<<  "
            + str(out)
            + "\n"
        )
        gLogFile.flush()

    except Exception, ex:
        printl2("Exception(" + str(type(ex)) + "): " + str(ex), "__common__::writeToLog", "E")
开发者ID:vega82,项目名称:DreamPlex,代码行数:36,代码来源:__common__.py

示例3: openLogFile

# 需要导入模块: from DPH_Singleton import Singleton [as 别名]
# 或者: from DPH_Singleton.Singleton import getLogFileInstance [as 别名]
def openLogFile():
    """
	singleton instance for logfile
	
	@param: none
	@return: none
	"""
    # printl2("", "openLogFile", "S")

    logDir = config.plugins.dreamplex.logfolderpath.value

    now = datetime.datetime.now()
    try:
        instance = Singleton()
        instance.getLogFileInstance(open(logDir + "dreamplex.log", "w"))

    except Exception, ex:
        printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile", "E")
开发者ID:vega82,项目名称:DreamPlex,代码行数:20,代码来源:__common__.py

示例4: openLogFile

# 需要导入模块: from DPH_Singleton import Singleton [as 别名]
# 或者: from DPH_Singleton.Singleton import getLogFileInstance [as 别名]
def openLogFile():
	"""
	singleton instance for logfile
	"""
	#printl2("", "openLogFile", "S")

	logDir = config.plugins.dreamplex.logfolderpath.value

	try:
		if os.path.exists(logDir + "dreamplex_former.log"):
			os.remove(logDir + "dreamplex_former.log")

		if os.path.exists(logDir + "dreamplex.log"):
			shutil.copy2(logDir + "dreamplex.log", logDir + "dreamplex_former.log")

		instance = Singleton()
		instance.getLogFileInstance(open(logDir + "dreamplex.log", "w"))

	except Exception, ex:
		printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile", "E")
开发者ID:DonDavici,项目名称:DreamPlex,代码行数:22,代码来源:__common__.py


注:本文中的DPH_Singleton.Singleton.getLogFileInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。