mirror of
https://github.com/kohya-ss/sd-scripts.git
synced 2026-04-06 13:47:06 +00:00
* Add get_my_logger() * Use logger instead of print * Fix log level * Removed line-breaks for readability * Use setup_logging() * Add rich to requirements.txt * Make simple * Use logger instead of print --------- Co-authored-by: Kohya S <52813779+kohya-ss@users.noreply.github.com>
24 lines
558 B
Python
24 lines
558 B
Python
import logging
|
|
import threading
|
|
from typing import *
|
|
|
|
|
|
def fire_in_thread(f, *args, **kwargs):
|
|
threading.Thread(target=f, args=args, kwargs=kwargs).start()
|
|
|
|
|
|
def setup_logging(log_level=logging.INFO):
|
|
if logging.root.handlers: # Already configured
|
|
return
|
|
|
|
from rich.logging import RichHandler
|
|
|
|
handler = RichHandler()
|
|
formatter = logging.Formatter(
|
|
fmt="%(message)s",
|
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
)
|
|
handler.setFormatter(formatter)
|
|
logging.root.setLevel(log_level)
|
|
logging.root.addHandler(handler)
|