1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-07 10:43:27 -04:00
- Add standardized class __init__ log function
  - Import logger from lib.__init__ to prevent custom log level errors when running non-fs scripts
This commit is contained in:
torzdf 2024-03-20 14:19:23 +00:00
parent 63b4d91281
commit 1009254c57
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,4 @@
#!/usr/bin/env python3
""" Initialization for faceswap's lib section """
# Import logger here so our custom loglevels are set for when executing code outside of FS
from . import logger

View file

@ -7,6 +7,7 @@ import os
import platform
import re
import sys
import typing as T
import time
import traceback
@ -543,6 +544,23 @@ def crash_log() -> str:
return filename
def parse_class_init(locals_dict: dict[str, T.Any]) -> str:
""" Parse a locals dict from a class and return in a format suitable for logging
Parameters
----------
locals_dict: dict[str, T.Any]
A locals() dictionary from a newly initialized class
Returns
-------
str
The locals information suitable for logging
"""
delimit = {k: f"'{v}'" if isinstance(v, str) else v
for k, v in locals_dict.items() if k != "self"}
dsp = ", ".join(f"{k}: {v}" for k, v in delimit.items())
return f"Initializing {locals_dict['self'].__class__.__name__} ({dsp})"
_OLD_FACTORY = logging.getLogRecordFactory()