1717from datetime import datetime
1818from inspect import getframeinfo , stack
1919from pathlib import Path
20- from typing import Any , NotRequired , TypeAlias , TypedDict , TypeVar
20+ from typing import Any , Final , NotRequired , TypeAlias , TypedDict , TypeVar
2121
2222from settings_library .tracing import TracingSettings
2323
@@ -109,7 +109,7 @@ def format(self, record) -> str:
109109
110110
111111# SEE https://docs.python.org/3/library/logging.html#logrecord-attributes
112- DEFAULT_FORMATTING = " | " .join (
112+ _DEFAULT_FORMATTING : Final [ str ] = " | " .join (
113113 [
114114 "log_level=%(levelname)s" ,
115115 "log_timestamp=%(asctime)s" ,
@@ -120,10 +120,12 @@ def format(self, record) -> str:
120120 ]
121121)
122122
123- LOCAL_FORMATTING = "%(levelname)s: [%(asctime)s/%(processName)s] [%(name)s:%(funcName)s(%(lineno)d)] - %(message)s"
123+ _LOCAL_FORMATTING : Final [str ] = (
124+ "%(levelname)s: [%(asctime)s/%(processName)s] [%(name)s:%(funcName)s(%(lineno)d)] - %(message)s"
125+ )
124126
125127# Tracing format strings
126- TRACING_FORMATTING = " | " .join (
128+ _TRACING_FORMATTING : Final [ str ] = " | " .join (
127129 [
128130 "log_level=%(levelname)s" ,
129131 "log_timestamp=%(asctime)s" ,
@@ -138,7 +140,7 @@ def format(self, record) -> str:
138140 ]
139141)
140142
141- LOCAL_TRACING_FORMATTING = (
143+ _LOCAL_TRACING_FORMATTING : Final [ str ] = (
142144 "%(levelname)s: [%(asctime)s/%(processName)s] "
143145 "[log_trace_id=%(otelTraceID)s log_span_id=%(otelSpanID)s "
144146 "log_resource.service.name=%(otelServiceName)s log_trace_sampled=%(otelTraceSampled)s] "
@@ -157,14 +159,14 @@ def _setup_format_string(
157159 """Create the appropriate format string based on settings."""
158160 if log_format_local_dev_enabled :
159161 if tracing_settings is not None :
160- return LOCAL_TRACING_FORMATTING
161- return LOCAL_FORMATTING
162+ return _LOCAL_TRACING_FORMATTING
163+ return _LOCAL_FORMATTING
162164
163165 if tracing_settings is not None :
164166 setup_log_tracing (tracing_settings = tracing_settings )
165- return TRACING_FORMATTING
167+ return _TRACING_FORMATTING
166168
167- return DEFAULT_FORMATTING
169+ return _DEFAULT_FORMATTING
168170
169171
170172def _set_logging_handler (
@@ -494,7 +496,7 @@ def __init__(
494496 ) -> None :
495497 self .handlers = handlers or [logging .StreamHandler ()]
496498 self .log_format_local_dev_enabled = log_format_local_dev_enabled
497- self .fmt = fmt or DEFAULT_FORMATTING
499+ self .fmt = fmt or _DEFAULT_FORMATTING
498500 self .queue : queue .Queue | None = None
499501 self .listener : logging .handlers .QueueListener | None = None
500502 self .queue_handler : logging .handlers .QueueHandler | None = None
0 commit comments