-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_manage.py
35 lines (29 loc) · 989 Bytes
/
log_manage.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
from datetime import datetime
class Log_manage:
def __init__(self):
self.f = None
self.time = datetime.now().strftime(" %d/%m/%Y %H:%M:%S ")
def open_file(self):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: open logs file
Return: Null"""
try:
self.f = open('logs', 'a')
return 1
except FileExistsError:
print('')
def write_to_log(self, city, message, value):
"""Author: Maor Maharizi,
Created: 30.01.2023,
Detail: write to logs file
Return: Null"""
self.f.write(f"\n {city} ! --- {message} --- value : {value} --- " + self.time)
self.f.write("")
self.f.flush()
def close_log_file(self):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: close logs file
Return: Null"""
self.f.close()