-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (18 loc) · 846 Bytes
/
utils.py
File metadata and controls
25 lines (18 loc) · 846 Bytes
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
import time, settings
from settings import LOGFILE_PATH, DEBUGFILE_PATH
CURRENT_HOUR = lambda: time.localtime().tm_hour
CURRENT_MIN = lambda: time.localtime().tm_min
CURRENT_TIME = lambda: f"[{time.localtime().tm_hour}:{time.localtime().tm_min}:{time.localtime().tm_sec}]"
CURRENT_DATE = lambda: f"[{time.localtime().tm_mon}/{time.localtime().tm_mday}/{time.localtime().tm_year}]"
def log(*content, timestamp = True, datestamp = True, sep = " ", logfile = DEBUGFILE_PATH):
if settings.DEBUG == False and logfile == DEBUGFILE_PATH:
return False
content = sep.join(content)
if timestamp:
content = CURRENT_TIME() + " " + str(content)
if datestamp:
content = CURRENT_DATE() + " " + str(content)
print(content)
open(logfile, "a").write(
str(content) + "\n"
)