-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.py
37 lines (36 loc) · 1.38 KB
/
Logger.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
import datetime, os
import configparser
from configparser import *
Config = configparser.ConfigParser()
class Log():
@staticmethod
def write(text):
Config.read("config.txt")
count = Config.get("Counter", "count")
count = int(count)
count += 1
now = datetime.datetime.now()
d = now.strftime("%Y-%m-%d")
newpath = rf'logs\{d}'
if not os.path.exists(newpath):
os.makedirs(newpath)
with open(file=f"logs\\{d}\\log-{count}.txt", mode="a") as conf:
now = datetime.datetime.now()
d = now.strftime("%Y-%m-%d")
h = datetime.datetime.now().hour # s
m = datetime.datetime.now().minute # d
s = datetime.datetime.now().second
conf.write(f"[{d} {h}:{m}:{s}] [LOG] {text}\n")
@staticmethod
def writeout(text):
now = datetime.datetime.now()
d = now.strftime("%Y-%m-%d")
h = datetime.datetime.now().hour # s
m = datetime.datetime.now().minute # d
s = datetime.datetime.now().second
newpath = rf'output\{d}'
if not os.path.exists(newpath):
os.makedirs(newpath)
with open(file=f"output\\{d}\\{d}-{h}-{m}-{s}.txt", mode="a") as conf:
now = datetime.datetime.now()
conf.write(f"[{d} {h}:{m}:{s}] [Account] {text}\n")