RFC: Structural logger #472
asmyasnikov
started this conversation in
Ideas
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Logger interface
Trace
,Debug
,Info
etc. can be turned into one methodLog(lvl Level)
, it is just a question of preferred styleObject
andArray
don't have to be inLogger
interface, we just need some factories to create the right objects. Putting these methods inLogger
seems to be simpler than creating another interface for factoriesRecord/Array interfaces
type Field struct {...}
in SDK, the logic of type-specific marshaling would just go intoLog
method:And this looks like an added complexity in adapter to me. I think that it's better for adapter to have a lot of boilerplate than a lot of complexity.
enabled
flag in record and making so that allRecord
methods (Int
,Bool
, etc.) are no-op for disabled records. This however won't help optimize nested structures:Need to think more about it.
type Field struct{...}
in SDK seems like duplicating some logic between SDK and adapters. For example, zap'sField
looks very much like it, so zap's adapter would have to convert a bunch ofydb.Field
intozap.Field
. Other implementations (like zerolog) don't have such struct, and instead they encode fields directly (example). So, zerolog adapter does not need such struct at all and will look very clean and straightforward with the current interface.Array
interface which duplicates almost all methods ofRecord
(withoutkey string
argument) also looks scary and redundant, but I still think that this boilerplate makes the resulting API less complex. I also strongly believe that supporting a lot of fundamental types + arbitrary nested structures (arrays and objects) is the best way to eliminate compatibility issues in the future. Two examples of this are already present in the PR.Beta Was this translation helpful? Give feedback.
All reactions