Skip to content

Commit

Permalink
chore: do not setup python logging facility in app mode
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Dec 2, 2024
1 parent 922919c commit cec4807
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions otterdog/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from otterdog.cache import get_github_cache

# enable debug outputs
init_logging(2)
init_logging(2, False)

app.logger.info("DEBUG = " + str(DEBUG))
app.logger.info("Environment = " + config_mode)
Expand All @@ -68,7 +68,7 @@
app.logger.info("TMP_DIR = " + tmp_dir)
else:
# setup app logging to level INFO
init_logging(1)
init_logging(1, False)


def run():
Expand Down
7 changes: 0 additions & 7 deletions otterdog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# *******************************************************************************

import asyncio
import logging
import sys
from typing import Any

Expand All @@ -28,12 +27,6 @@

_CONFIG: OtterdogConfig | None = None

logging.basicConfig(
level=logging.WARNING,
format="%(message)s",
datefmt="%X.%f",
)


def complete_organizations(ctx, param, incomplete):
config_file = ctx.params.get("config")
Expand Down
24 changes: 15 additions & 9 deletions otterdog/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def trace(self, msg, *args, **kwargs):
logging.setLoggerClass(CustomLogger)


def init_logging(verbose: int) -> None:
def init_logging(verbose: int, setup_python_logger: bool = True) -> None:
global _verbose_level
_verbose_level = verbose

Expand All @@ -74,15 +74,21 @@ def init_logging(verbose: int) -> None:
level = TRACE
show_time = True

logging.root.addHandler(
RichHandler(
rich_tracebacks=True,
tracebacks_show_locals=True,
show_time=show_time,
omit_repeated_times=False,
console=CONSOLE_STDOUT,
if setup_python_logger is True:
logging.basicConfig(
level=logging.WARNING,
format="%(message)s",
datefmt="%X.%f",
handlers=[
RichHandler(
rich_tracebacks=True,
tracebacks_show_locals=True,
show_time=show_time,
omit_repeated_times=False,
console=CONSOLE_STDOUT,
)
],
)
)

import otterdog

Expand Down

0 comments on commit cec4807

Please sign in to comment.