cocluto/ClusterController/Log.py

30 lines
546 B
Python

import time
import threading
gLogFilePath = '/var/log/ClusterController.log'
def log( message ):
threadName = threading.currentThread().getName()
logMessage = time.asctime(time.localtime())+' : '+ threadName + ' : ' + message
print logMessage
f = open(gLogFilePath, 'a+')
assert( f )
try:
f.write( logMessage + '\n' )
finally:
f.close()
def logDebug( message ):
log('[D]'+message)
return
def logInfo( message ):
log('[I]'+message)
def logWarning( message ):
log('[W]'+message)
def logError( message ):
log('[E]'+message)