Class swarmauri_standard.logger_formatters.ContextualFormatter.ContextualFormatterImpl
ContextualFormatterImpl(
    fmt=None,
    datefmt=None,
    context_keys=None,
    context_as_prefix=False,
    context_separator=" ",
    context_prefix="[",
    context_suffix="]",
    context_item_format="{key}={value}",
    include_empty_context=False,
    **kwargs,
)
              Bases: Formatter
Implementation of the contextual formatter logic.
This class extends the standard logging.Formatter to include contextual information from LogRecord attributes.
Initialize the contextual formatter.
| PARAMETER | DESCRIPTION | 
|---|---|
| fmt | The base format string 
                  
                    TYPE:
                       | 
| datefmt | The date format string 
                  
                    TYPE:
                       | 
| context_keys | List of attribute names to extract from LogRecord 
                  
                    TYPE:
                       | 
| context_as_prefix | Whether to format context as a prefix 
                  
                    TYPE:
                       | 
| context_separator | Separator between context items 
                  
                    TYPE:
                       | 
| context_prefix | Prefix for the entire context section 
                  
                    TYPE:
                       | 
| context_suffix | Suffix for the entire context section 
                  
                    TYPE:
                       | 
| context_item_format | Format for each context item (when not prefix mode) 
                  
                    TYPE:
                       | 
| include_empty_context | Whether to include context section when all values are missing 
                  
                    TYPE:
                       | 
| **kwargs | Additional arguments passed to logging.Formatter 
                  
                    DEFAULT:
                       | 
Source code in swarmauri_standard/logger_formatters/ContextualFormatter.py
                    | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |  | 
instance-attribute
  
context_keys = context_keys or ['request_id', 'user_id']
instance-attribute
  
context_as_prefix = context_as_prefix
instance-attribute
  
context_separator = context_separator
instance-attribute
  
context_prefix = context_prefix
instance-attribute
  
context_suffix = context_suffix
instance-attribute
  
context_item_format = context_item_format
instance-attribute
  
include_empty_context = include_empty_context
format(record)
Format the specified record as text with added context.
| PARAMETER | DESCRIPTION | 
|---|---|
| record | The log record to format 
                  
                    TYPE:
                       | 
| RETURNS | DESCRIPTION | 
|---|---|
| str | The formatted log message with context 
                  
                    TYPE:
                       | 
Source code in swarmauri_standard/logger_formatters/ContextualFormatter.py
              | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |  |