mirror of
https://github.com/ION606/ML-pipeline.git
synced 2026-05-15 05:16:54 +00:00
added rudamentary search and code execution
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import datetime
|
||||
import os
|
||||
from config import Config
|
||||
|
||||
|
||||
def log(txt, wrapped=False):
|
||||
try:
|
||||
if not os.path.exists(Config.LOG_DIR):
|
||||
os.makedirs(Config.LOG_DIR)
|
||||
|
||||
with open(Config.debug_log_path(), 'a') as f:
|
||||
if wrapped:
|
||||
f.write('==============================================\n')
|
||||
|
||||
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
lines = txt.split('\n')
|
||||
for i, line in enumerate(lines):
|
||||
prefix = f"{timestamp} - " if i == 0 else " " * \
|
||||
len(timestamp) + " "
|
||||
f.writelines([f"{prefix}{line}\n"])
|
||||
|
||||
if wrapped:
|
||||
f.write('==============================================\n')
|
||||
except Exception as e:
|
||||
print(f"Failed to write to debug.txt: {e}")
|
||||
|
||||
|
||||
def moveDebugLog():
|
||||
deblogpath = os.path.join(Config.LOG_DIR, 'debug.txt')
|
||||
if os.path.exists(Config.debug_log_path()):
|
||||
os.rename(deblogpath, os.path.join(Config.LOG_DIR, 'old-debug.txt'))
|
||||
Reference in New Issue
Block a user