File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,9 +120,15 @@ def __init__(
120120 ) -> None :
121121 # Set default format if none provided - compact level, env tag, and PID
122122 if fmt is None :
123- fmt = "%(asctime)s [%(levelname)s] [%(env_tag)s] [pid=%(process)d] %(name)s:%(lineno)d %(message)s"
123+ fmt = "%(asctime)s [%(levelname)s] [%(env_tag)s] [pid=%(process)d] [stream_id=%(stream_id)s] %(name)s:%(lineno)d %(message)s"
124124 super ().__init__ (fmt , datefmt , style = style )
125125
126+ def format (self , record : logging .LogRecord ) -> str :
127+ """Populate optional logging fields used by the global format."""
128+ if not hasattr (record , "stream_id" ):
129+ record .stream_id = "-"
130+ return super ().format (record )
131+
126132
127133# Default set of fields to redact
128134DEFAULT_REDACTED_FIELDS = {
@@ -564,7 +570,7 @@ def configure_logging_with_environment_tagging(
564570 """
565571 # Use default format with environment tag if none provided - compact level, env tag, and PID
566572 if log_format is None :
567- log_format = "%(asctime)s [%(levelname)s] [%(env_tag)s] [pid=%(process)d] %(name)s:%(lineno)d %(message)s"
573+ log_format = "%(asctime)s [%(levelname)s] [%(env_tag)s] [pid=%(process)d] [stream_id=%(stream_id)s] %(name)s:%(lineno)d %(message)s"
568574
569575 # Create formatter with environment tag support
570576 formatter = EnvironmentTaggingFormatter (fmt = log_format )
You can’t perform that action at this time.
0 commit comments