Skip to content

Commit

Permalink
feat: remove unused log part
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYanZh committed Nov 30, 2024
1 parent 0648024 commit 7efd525
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions joint_teapot/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

# recipe from https://loguru.readthedocs.io/en/stable/overview.html#entirely-compatible-with-standard-logging
class InterceptHandler(logging.Handler):
def __init__(self, diagnose: bool = True, backtrace: bool = True):
def __init__(self) -> None:
super().__init__()
self.diagnose = diagnose
self.backtrace = backtrace

def emit(self, record: logging.LogRecord) -> None:
try:
Expand All @@ -30,25 +28,19 @@ def emit(self, record: logging.LogRecord) -> None:
depth += 1

logger.opt(depth=depth, exception=record.exc_info).log(
level, record.getMessage(), diagnose=self.diagnose, backtrace=self.backtrace
level,
record.getMessage(),
)


def set_logger(
stderr_log_level: str = settings.stderr_log_level,
*,
diagnose: bool = True,
backtrace: bool = True,
) -> None:
logging.basicConfig(
handlers=[InterceptHandler(diagnose, backtrace)], level=0, force=True
)
logging.basicConfig(handlers=[InterceptHandler()], level=0, force=True)
logger.remove()
logger.add(
stderr,
level=stderr_log_level,
diagnose=diagnose,
backtrace=backtrace,
)
logger.add(settings.log_file_path, level="DEBUG")

Expand Down

0 comments on commit 7efd525

Please sign in to comment.