# -*- coding: utf-8 -*-
'''global logfile management'''
import globalv, os, thread, time

__log = open(globalv.GLOBAL_LOG, 'w')
__logLock = thread.allocate_lock()

def write(message):
    entry = str(time.ctime()) + ' : ' + str(message)
    __logLock.acquire()
    __log.write(entry)
    __log.flush()
    __logLock.release()
    
def close():
    __logLock.acquire()
    __log.close()
    __logLock.release()
    os.rename(globalv.GLOBAL_LOG, globalv.GLOBAL_LOG + '.0')
    
