-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.py
49 lines (35 loc) · 1.05 KB
/
errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import sys
import traceback
# error_output = "desk_schedule_errors.txt"
error_output_header = "This is the desk_schedule log for errors and warnings. Do not archive.\n"
# log_output = "desk_schedule_log.txt"
def log_error_message(error_output, message):
f_err = open(error_output, "a")
f_err.write(message + '\n')
f_err.close()
def log_message(log_output, message):
f_log = open(log_output, "a")
f_log.write(message + '\n')
f_log.close()
def init_error_log(error_output):
# delete existing logfile unless it doesn't exist
try:
os.remove(error_output)
except OSError:
pass
f_err = open(error_output, "w")
f_err.write(error_output_header)
f_err.close()
def get_stack_trace(e):
T, V, TB = sys.exc_info()
trace = ''.join(traceback.format_exception(T, V, TB))
return trace
def init_main_log(log_output):
# delete existing logfile unless it doesn't exist
try:
os.remove(log_output)
except OSError:
pass
f_log = open(log_output, "w")
f_log.close()