-
Notifications
You must be signed in to change notification settings - Fork 2
/
chronicle_engine.py
48 lines (41 loc) · 1.22 KB
/
chronicle_engine.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
import os
import sys
import time
import datetime
log_folder = os.path.exists("Activity Logs")
if log_folder == False:
os.mkdir("Activity Logs")
elif log_folder == True:
pass
date = datetime.datetime.now().strftime("%h:%H:%M:%S")
act_log = str(date).replace(":", "-") + "-Log.txt"
#first of all create a folder named Activity Logs
folder = "Activity Logs"
save_path = os.path.join(folder, act_log)
def chronicle_log(write, incog):
#enabled activity logging
if incog == 0:
print_save = sys.stdout
f = open(save_path, 'a', encoding="utf-8")
sys.stdout = f
y = write
print(y)
sys.stdout = print_save
f.close()
#disabled activity logging
elif incog == 1:
print_save = sys.stdout
f = open(save_path, 'a', encoding="utf-8")
sys.stdout = f
y = write
pass
#activity logging diabled
sys.stdout = print_save
f.close()
def clean_slate():
mydir = "Activity Logs"
txtfiles = [f for f in os.listdir(mydir) if f.endswith(".txt")]
for f in txtfiles:
os.remove(os.path.join(mydir, f))
time.sleep(1)
#deletes all activity log files in the folder