當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。