-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogs.py
34 lines (29 loc) · 937 Bytes
/
logs.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
import uio
class logger():
totalsize = 0
filename = ""
def __init__(self, filename, sizeinbytes = 1024):
self.totalsize = int(sizeinbytes)
if filename == "":
self.filename = "log.txt"
else:
self.filename = filename
with uio.open(self.filename, "w") as f:
f.write("")
f.close()
def __del__(self):
pass
def write(self,value):
buffer = ""
with uio.open(self.filename, "r") as f:
buffer = f.read()
f.close()
with uio.open(self.filename, "w") as f:
buffer + "\r\n{0}".format(value)
print(value)
if len(buffer) < self.totalsize:
f.write(buffer + "\r\n{0}".format(value))
else:
f.write("\r\n{0}".format(value))
f.flush()
f.close()