Browse Source

feat: add timestamp to log file

pull/289/head
dr.lt.data 11 months ago
parent
commit
bf25d0208a
  1. 4
      __init__.py
  2. 8
      prestartup_script.py

4
__init__.py

@ -27,7 +27,7 @@ except:
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.") print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
version = [1, 21] version = [1, 23]
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '') version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
print(f"### Loading: ComfyUI-Manager ({version_str})") print(f"### Loading: ComfyUI-Manager ({version_str})")
@ -35,9 +35,9 @@ print(f"### Loading: ComfyUI-Manager ({version_str})")
required_comfyui_revision = 1793 required_comfyui_revision = 1793
comfy_ui_hash = "-" comfy_ui_hash = "-"
cache_lock = threading.Lock() cache_lock = threading.Lock()
def handle_stream(stream, prefix): def handle_stream(stream, prefix):
stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace') stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace')
for msg in stream: for msg in stream:

8
prestartup_script.py

@ -142,6 +142,7 @@ try:
def __init__(self, is_stdout): def __init__(self, is_stdout):
self.is_stdout = is_stdout self.is_stdout = is_stdout
self.encoding = "utf-8" self.encoding = "utf-8"
self.last_char = ''
def fileno(self): def fileno(self):
try: try:
@ -193,8 +194,13 @@ try:
def sync_write(self, message): def sync_write(self, message):
with log_lock: with log_lock:
log_file.write(message) timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')[:-3]
if self.last_char != '\n':
log_file.write(message)
else:
log_file.write(f"[{timestamp}] {message}")
log_file.flush() log_file.flush()
self.last_char = message[-1]
with std_log_lock: with std_log_lock:
if self.is_stdout: if self.is_stdout:

Loading…
Cancel
Save