summaryrefslogtreecommitdiff
path: root/common.py
blob: 7a70a8b1c0319a50935e008ea7591e1adf8e3e52 (plain)
1
2
3
4
5
6
7
8
9
10
def log(logfile,component,msg):
    ''' write message to log file with timestamp and script name '''
    import datetime
    _component = str(component)
    _msg = str(msg)
    dt = str(datetime.datetime.now()).split('.')[0]
    to_log = "[%s][%s] %s" % (dt, _component, _msg)
    log_file = open(LOGFILE,'a')
    log_file.write('%s\n' % to_log)
    log_file.close()