pkg/logger/lk: new package for log key glossary
This PR introduces a new package logkey to serve as a glossary of logger keys in order to align common fields.
Supports:
- https://github.com/smartcontractkit/chainlink/pull/15936
This PR introduces a new
package logkeyto serve as a glossary of logger keys in order to align common fields.
What is the intended use of the keys from logkey? Is this for labelling with ZAP's zap.String(key, value) construction, or is it for arbitrary string / int constants that can be used for logging in a centralized way?
This PR introduces a new
package logkeyto serve as a glossary of logger keys in order to align common fields.What is the intended use of the keys from logkey? Is this for labelling with ZAP's zap.String(key, value) construction, or is it for arbitrary string / int constants that can be used for logging in a centralized way?
We don't typically use the zap field API like that, but that would be valid. More often we just call the w variants: Logger.<level>w("<message>", logkey.ChainID, chainID)
This PR introduces a new
package logkeyto serve as a glossary of logger keys in order to align common fields.What is the intended use of the keys from logkey? Is this for labelling with ZAP's zap.String(key, value) construction, or is it for arbitrary string / int constants that can be used for logging in a centralized way?
We don't typically use the zap field API like that, but that would be valid. More often we just call the
wvariants:Logger.<level>w("<message>", logkey.ChainID, chainID)
I see, so are you planning to extract all the possible keys in some kind of automatic way? Or would you just keep adding them here continuously?
This PR introduces a new
package logkeyto serve as a glossary of logger keys in order to align common fields.What is the intended use of the keys from logkey? Is this for labelling with ZAP's zap.String(key, value) construction, or is it for arbitrary string / int constants that can be used for logging in a centralized way?
We don't typically use the zap field API like that, but that would be valid. More often we just call the
wvariants:Logger.<level>w("<message>", logkey.ChainID, chainID)I see, so are you planning to extract all the possible keys in some kind of automatic way? Or would you just keep adding them here continuously?
We could try to start with some automation, but adding keys manually would be sufficient for most common inconsistencies.
I did consider providing zap field support as well, but I'm not sure how that should work. Even just ChainID is an interesting example. We probably would want to encourage (or even enforce) string based chain IDs, but we don't want to force callers to make a string to pass in, since that is inefficient in cases where the log message does not need to be serialized. We'd rather also accept fmt.Stringer. So zapfield.ChainID("string") isn't flexible enough, we'd want a fmt.Stringer version, and probably int64 too. It wasn't obvious to me how to sort that out in a clean way, so I left it out of scope for now.
This PR introduces a new
package logkeyto serve as a glossary of logger keys in order to align common fields.What is the intended use of the keys from logkey? Is this for labelling with ZAP's zap.String(key, value) construction, or is it for arbitrary string / int constants that can be used for logging in a centralized way?
We don't typically use the zap field API like that, but that would be valid. More often we just call the
wvariants:Logger.<level>w("<message>", logkey.ChainID, chainID)I see, so are you planning to extract all the possible keys in some kind of automatic way? Or would you just keep adding them here continuously?
We could try to start with some automation, but adding keys manually would be sufficient for most common inconsistencies.
I did consider providing zap field support as well, but I'm not sure how that should work. Even just
ChainIDis an interesting example. We probably would want to encourage (or even enforce)stringbased chain IDs, but we don't want to force callers to make astringto pass in, since that is inefficient in cases where the log message does not need to be serialized. We'd rather also acceptfmt.Stringer. Sozapfield.ChainID("string")isn't flexible enough, we'd want afmt.Stringerversion, and probablyint64too. It wasn't obvious to me how to sort that out in a clean way, so I left it out of scope for now.
Sound good. Thanks for explaining!
This PR is stale because it has been open 30 days with no activity.
Remove the stale label or comment or this will be closed in 7 days.
This PR is stale because it has been open 30 days with no activity.
Remove the stale label or comment or this will be closed in 7 days.
This PR has been automatically closed because it has been stale for > 30 days. If you wish to continue working on this PR, please reopen it and make any necessary changes.