This commit is contained in:
mojunze
2026-10-20 12:53:02 +08:00
parent df431b3641
commit 23f81ef0c4
20 changed files with 34496 additions and 216 deletions
+32
View File
@@ -0,0 +1,32 @@
import os
from datetime import datetime
class Logger:
log_dir = 'logs'
os.makedirs(log_dir, exist_ok=True)
GREEN = '\033[92m'
BLUE = '\033[94m'
RED = '\033[91m'
RESET = '\033[0m'
log_file_path = os.path.join(log_dir, f'{datetime.now().strftime("%Y-%m-%d")}.txt')
@staticmethod
def _write_to_file(level, message):
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
log_entry = f"{timestamp} [{level}] {message}\n"
with open(Logger.log_file_path, 'a', encoding='utf-8') as f:
f.write(log_entry)
@staticmethod
def success(message):
print(f"{Logger.GREEN}[+] {message}{Logger.RESET}")
Logger._write_to_file('SUCCESS', message)
@staticmethod
def info(message):
print(f"{Logger.BLUE}[*] {message}{Logger.RESET}")
Logger._write_to_file('INFO', message)
@staticmethod
def error(message):
print(f"{Logger.RED}[!] {message}{Logger.RESET}")
Logger._write_to_file('ERROR', message)