def error_log(self, error, station_name=None):
if os.path.isfile('error_log.txt'):
file = open('error_log.txt', 'a')
else:
file = open('error_log.txt', 'w')
if not station_name:
station_name = 'NO-STATION-NAME'
# Create time stamp
time_stamp = time.asctime(time.localtime(time.time()))
# Form error message 'Station == Time == Error'
error_msg = str(station_name) + '\t' + time_stamp + '\t' + str(error) + '\n'
file.write(error_msg)
file.close()
评论列表
文章目录