|
5 | 5 |
|
6 | 6 | import ddtrace
|
7 | 7 | from ddtrace import config
|
8 |
| -from ddtrace._logger import LogInjectionState |
9 | 8 | from ddtrace._logger import set_log_formatting
|
10 | 9 | from ddtrace.contrib.internal.trace_utils import unwrap as _u
|
11 | 10 | from ddtrace.internal.constants import LOG_ATTR_ENV
|
@@ -54,15 +53,13 @@ def __init__(self, trace_id: int, span_id: int, service: str, version: str, env:
|
54 | 53 | def _w_makeRecord(func, instance, args, kwargs):
|
55 | 54 | # Get the LogRecord instance for this log
|
56 | 55 | record = func(*args, **kwargs)
|
57 |
| - if config._logs_injection == LogInjectionState.DISABLED: |
58 |
| - # log injection is opt-in for non-structured logging |
59 |
| - return record |
60 |
| - record.__dict__.update(ddtrace.tracer.get_log_correlation_context()) |
| 56 | + if config._logs_injection: |
| 57 | + record.__dict__.update(ddtrace.tracer.get_log_correlation_context()) |
61 | 58 | return record
|
62 | 59 |
|
63 | 60 |
|
64 | 61 | def _w_StrFormatStyle_format(func, instance, args, kwargs):
|
65 |
| - if config._logs_injection != LogInjectionState.ENABLED: |
| 62 | + if not config._logs_injection: |
66 | 63 | return func(*args, **kwargs)
|
67 | 64 | # The format string "dd.service={dd.service}" expects
|
68 | 65 | # the record to have a "dd" property which is an object that
|
@@ -103,7 +100,7 @@ def patch():
|
103 | 100 | _w(logging.Logger, "makeRecord", _w_makeRecord)
|
104 | 101 | _w(logging.StrFormatStyle, "_format", _w_StrFormatStyle_format)
|
105 | 102 |
|
106 |
| - if config._logs_injection == LogInjectionState.ENABLED: |
| 103 | + if config._logs_injection: |
107 | 104 | # Only set the formatter is DD_LOGS_INJECTION is set to True. We do not want to modify
|
108 | 105 | # unstructured logs if a user has not enabled logs injection.
|
109 | 106 | # Also, the Datadog log format must be set after the logging module has been patched,
|
|
0 commit comments