You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The processor formatter uses this line to distinguish between Structlog and regular messages:
if isinstance(record.msg, dict):
Unfortunately this runs afoul of any library or bug which happens to accidentally pass a dict object to the Python standard library logger (in the wild I've found the connexion library does this in some of its initialization code, producing exceptions when using structlog). This happens because the record entry doesn't have _logger attached because it didn't come through structlog.
IMO the ideal solution would be for the wrap_for_formatter handler to actually supply a wrapped dictionary type which could be tested for directly, but this doesn't seem particularly viable.
The best solution therefore is probably to embrace duck-typing in this code path and change the check to ensure the expected attributes are actually there:
if isinstance(record.msg, dict) and hasattr(record, "_logger") and hasattr(record,"_name"):
The text was updated successfully, but these errors were encountered:
The processor formatter uses this line to distinguish between Structlog and regular messages:
Unfortunately this runs afoul of any library or bug which happens to accidentally pass a
dict
object to the Python standard library logger (in the wild I've found the connexion library does this in some of its initialization code, producing exceptions when using structlog). This happens because therecord
entry doesn't have_logger
attached because it didn't come through structlog.IMO the ideal solution would be for the
wrap_for_formatter
handler to actually supply a wrapped dictionary type which could be tested for directly, but this doesn't seem particularly viable.The best solution therefore is probably to embrace duck-typing in this code path and change the check to ensure the expected attributes are actually there:
The text was updated successfully, but these errors were encountered: