Skip to content

Commit

Permalink
fix: remove duplicate logging setup
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusSagen committed Oct 12, 2024
1 parent 881fc39 commit 328333d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ doctest_optionflags = [
]

[tool.pytest_env]
# Mock some of the envs in `src/heimdall/constants.py`
LOG_LEVEL = "CRITICAL" # INFO, WARNING, ERROR, CRITICAL
REJX_LOG_LEVEL = "INFO" # INFO, WARNING, ERROR, CRITICAL

[tool.mypy]
plugins = []
Expand Down
2 changes: 2 additions & 0 deletions src/rejx/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Rejx."""

from __future__ import annotations

from rejx.cli import app

if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion src/rejx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
from rich.text import Text

import rejx.utils
from rejx.logger import logger
from rejx.logger import logger, setup_logger

app = typer.Typer()

setup_logger()


@app.command()
def fix(
Expand Down
23 changes: 11 additions & 12 deletions src/rejx/logger.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from __future__ import annotations

import logging
import os

from rich.logging import RichHandler

logging.basicConfig(
level=logging.INFO,
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(rich_tracebacks=True)],
)
__all__ = ["logger", "setup_logger"]

console = logging.StreamHandler()
console.setLevel(logging.DEBUG)

formatter = logging.Formatter("%(name)-12s: %(levelname)-8s %(message)s'")
console.setFormatter(formatter)
logging.getLogger("").addHandler(console)
def setup_logger() -> None:
logging.basicConfig(
level=os.getenv("REJX_LOG_LEVEL", logging.INFO),
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(rich_tracebacks=True)],
)

logger = logging.getLogger(__name__)

logger = logging.getLogger("rich")

0 comments on commit 328333d

Please sign in to comment.