Esempio n. 1
0
def openLogFile():
    '''
	singleton instance for logfile
	
	@param: none
	@return: none
	'''
    #printl2("", "openLogFile", "S")

    baseDir = config.plugins.pvmc.tmpfolderpath.value
    logDir = baseDir + "/log"

    now = datetime.datetime.now()
    try:
        if os.path.exists(logDir + "valerie_former.log"):
            os.remove(logDir + "valerie_former.log")

        if os.path.exists(logDir + "valerie.log"):
            shutil.copy2(logDir + "valerie.log", logDir + "valerie_former.log")

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

    except Exception, ex:
        printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile",
                "E")
Esempio n. 2
0
def openLogFile():
	'''
	singleton instance for logfile
	
	@param: none
	@return: none
	'''
	#printl2("", "openLogFile", "S")
	
	baseDir = config.plugins.pvmc.tmpfolderpath.value
	logDir = baseDir + "/log"
	
	now = datetime.datetime.now()
	try:
		if os.path.exists(logDir + "valerie_former.log"):
			os.remove(logDir + "valerie_former.log")
			
		if os.path.exists(logDir + "valerie.log"):
			shutil.copy2(logDir + "valerie.log", logDir + "valerie_former.log")
		
		instance = Singleton()
		instance.getLogFileInstance(open(logDir + "valerie.log", "w"))
		
	except Exception, ex:
		printl2("Exception(" + str(type(ex)) + "): " + str(ex), "openLogFile", "E")
Esempio n. 3
0
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:
        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")
Esempio n. 4
0
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:
		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")