1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 16:27:13 +03:00

Merge pull request #1046 from EDCD/enhancement/logging-class-def-frame

EDMCLogging: No fn.__qualname__ ?  Just use `name`.
This commit is contained in:
Athanasius 2021-05-10 15:38:37 +01:00 committed by GitHub
commit 29e72031d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -363,6 +363,9 @@ class EDMCContextFilter(logging.Filter):
else:
caller_qualname = f"<property {name} on {class_name}>"
elif not hasattr(fn, '__qualname__'):
caller_qualname = name
elif hasattr(fn, '__qualname__') and fn.__qualname__:
caller_qualname = fn.__qualname__

View File

@ -1,3 +1,4 @@
"""Test that logging works correctly from a class-definition caller."""
import sys
sys.path += "../" # Dont ask me why for this one it breaks, it just does.
@ -15,17 +16,17 @@ class ClassVarLogger:
"""Test class with logger attached."""
@classmethod
def set_logger(cls, logger):
def set_logger(cls, logger) -> None:
"""Set the passed logger onto the _class_."""
ClassVarLogger.logger = logger
ClassVarLogger.logger = logger # type: ignore
def log_stuff(msg: str):
"""Wrapper logger func."""
def log_stuff(msg: str) -> None:
"""Wrap logging in another function."""
ClassVarLogger.logger.debug(msg) # type: ignore # its there
def test_class_logger(caplog: 'LogCaptureFixture'):
def test_class_logger(caplog: 'LogCaptureFixture') -> None:
"""
Test that logging from a class variable doesn't explode.