fluent-logger-python icon indicating copy to clipboard operation
fluent-logger-python copied to clipboard

added explicit type cast to string to `FluentRecordFormatter` for `exclude_attrs` case.

Open mastak opened this issue 7 years ago • 1 comments

Case:

  1. Using FluentRecordFormatter with exclude_attrs=[].
  2. Create log record with uuid: logger.info('Some info', uuid=uuid4())
  3. catch TypeError: can't serialize UUID('fea00603-ef79-4f11-aff5-b05ee2f68111')

msgpack has limitations for input data, so it has to be cast to simple data types.

mastak avatar Apr 13 '18 09:04 mastak

Sorry, no. While the intention is good, you're going to be force-casting numbers and other simple types that msgpack does support into a string as well, including arrays and dicts, which is not a valid blanket conversion (people log primitive data structures via fluent all the time).

Please also see: https://github.com/msgpack/msgpack-python#packingunpacking-of-custom-data-type

arcivanov avatar Apr 13 '18 15:04 arcivanov