Skip to content

Commit

Permalink
Log to tauon.log too if debug is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rn3j committed Jan 20, 2025
1 parent 672b5b7 commit 811fb28
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tauon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@

from tauon.t_modules import t_bootstrap

debug = False
if (install_directory / "debug").is_file():
debug = True

log = LogHistoryHandler()
formatter = logging.Formatter('[%(levelname)s] %(message)s')
log.setFormatter(formatter)
Expand All @@ -84,7 +88,7 @@
)
# INFO+ to std_err
# TODO(Martin): This hereabout section is wonk, setting INFO on streamhandler removes formatting for DEBUG
logging.getLogger().handlers[0].setLevel(logging.DEBUG if (install_directory / "debug").is_file() else logging.INFO)
logging.getLogger().handlers[0].setLevel(logging.DEBUG if debug else logging.INFO)
logging.getLogger().handlers[0].setFormatter(CustomLoggingFormatter())

# https://docs.python.org/3/library/warnings.html
Expand Down Expand Up @@ -193,6 +197,12 @@ def transfer_args_and_exit() -> None:
if not user_directory.is_dir():
user_directory.mkdir(parents=True)

if debug:
file_handler = logging.FileHandler(user_directory / "tauon.log")
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)
logging.getLogger().addHandler(file_handler)

fp = None
dev_mode = (install_directory / ".dev").is_file()
if dev_mode:
Expand Down

0 comments on commit 811fb28

Please sign in to comment.