Open erdnaxeli opened 3 years ago
This is not caused by a union type, but UInt8
is not supported:
Log.info &.emit("test", a: 0_u8) # Error: no overload matches 'Log::Metadata::Value.new' with type UInt8
The log metadata is represented as a relatively simple data structure which supports only a hand full of primitive data types for values.
You'll have to convert the number to Int32
to pass it as log metadata. Or use some other form of serialization.
The supported types are the ones listed in https://crystal-lang.org/api/1.0.0/Log/Metadata/Value/Type.html . The actionable here is to improve the docs of emit. It is not expected for the Log::Metadata
to handle arbitrary types.
Well, neither Union
nor UInt8
feels like arbitrary types to me :p. Maybe we should add for all primitive types (U)Int?
It is very arbitrary. For logging purposes, there's not much reason to preserve specific integer types. Just convert it to Int32.
Hi,
With this code
I got the following error:
I see by diging in the doc that it exists
Log::Metadata::Value::Type
that define all supported types but:emit
docp!