cocluto/ClusterController/Log.py

30 lines
575 B
Python

import time
import threading
gLogFilePath = '/tmp/ClusterController.log'#'/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)