|
11 | 11 | from sentry_sdk.envelope import Envelope |
12 | 12 | from sentry_sdk.transport import Transport |
13 | 13 |
|
14 | | -from common.core.logging import JsonFormatter, setup_logging |
| 14 | +from common.core.logging import setup_logging |
15 | 15 |
|
16 | 16 | if TYPE_CHECKING: |
17 | 17 | from sentry_sdk._types import Event |
@@ -49,61 +49,6 @@ def sentry_transport_mock() -> Generator[MockSentryTransport, None, None]: |
49 | 49 | sentry_sdk.init(transport=None) |
50 | 50 |
|
51 | 51 |
|
52 | | -@pytest.mark.freeze_time("2023-12-08T06:05:47+00:00") |
53 | | -def test_json_formatter__format_log__outputs_expected( |
54 | | - caplog: pytest.LogCaptureFixture, |
55 | | - request: pytest.FixtureRequest, |
56 | | -) -> None: |
57 | | - # Given |
58 | | - json_formatter = JsonFormatter() |
59 | | - |
60 | | - caplog.handler.setFormatter(json_formatter) |
61 | | - logger = logging.getLogger("test_json_formatter__outputs_expected") |
62 | | - logger.setLevel(logging.INFO) |
63 | | - |
64 | | - expected_pid = os.getpid() |
65 | | - expected_module_path = os.path.abspath(request.path) |
66 | | - |
67 | | - def _log_traceback() -> None: |
68 | | - try: |
69 | | - raise Exception() |
70 | | - except Exception as exc: |
71 | | - logger.error("this is an error", exc_info=exc) |
72 | | - |
73 | | - expected_lineno = _log_traceback.__code__.co_firstlineno + 2 |
74 | | - expected_tb_string = ( |
75 | | - "Traceback (most recent call last):\n" |
76 | | - f' File "{expected_module_path}",' |
77 | | - f" line {expected_lineno}, in _log_traceback\n" |
78 | | - " raise Exception()\nException" |
79 | | - ) |
80 | | - |
81 | | - # When |
82 | | - logger.info("hello %s, %d", "arg1", 22.22) |
83 | | - _log_traceback() |
84 | | - |
85 | | - # Then |
86 | | - assert [json.loads(message) for message in caplog.text.split("\n") if message] == [ |
87 | | - { |
88 | | - "levelname": "INFO", |
89 | | - "message": "hello arg1, 22", |
90 | | - "timestamp": "2023-12-08 06:05:47,000", |
91 | | - "logger_name": "test_json_formatter__outputs_expected", |
92 | | - "pid": expected_pid, |
93 | | - "thread_name": "MainThread", |
94 | | - }, |
95 | | - { |
96 | | - "levelname": "ERROR", |
97 | | - "message": "this is an error", |
98 | | - "timestamp": "2023-12-08 06:05:47,000", |
99 | | - "logger_name": "test_json_formatter__outputs_expected", |
100 | | - "pid": expected_pid, |
101 | | - "thread_name": "MainThread", |
102 | | - "exc_info": expected_tb_string, |
103 | | - }, |
104 | | - ] |
105 | | - |
106 | | - |
107 | 52 | def test_setup_logging__generic_format__configures_stdlib( |
108 | 53 | capsys: pytest.CaptureFixture[str], |
109 | 54 | test_app_loggers: list[str], |
|
0 commit comments