forked from aminrd/LineamentLearning
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLogger.py
More file actions
26 lines (18 loc) · 637 Bytes
/
Copy pathLogger.py
File metadata and controls
26 lines (18 loc) · 637 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
# Logger class:
# To log special events and append to a file after running
__author__ = "Amin Aghaee"
__copyright__ = "Copyright 2018, Amin Aghaee"
import datetime
class Logger:
"""To log special events and append to a file after running"""
def __init__(self, fname = './log.txt'):
self.fname = fname
def addlog(self, message = None):
if message is None:
return 1
try:
with open(self.fname, "a") as f:
fmessage = str(datetime.datetime.now()) + " : " + message + "\n"
f.write(fmessage)
except:
print("Failed to log!")