Assert log fields are populated correctly
Implementation guide:
The following discussion from !794 (merged) should be addressed:
-
@bwill started a discussion: (+2 comments) @feistel LGTM! I wonder if we should have tests for this? We could create a function to retrieve the fields like
func configLogFields(config *Config) log.Fields. Then, we can test it by passing aConfigand asserting that the returnedlog.Fieldshas the values which we expect.@jaime: Thanks for the suggestion @bwill! I wonder if it's worth it? Do we do that in other projects? What's the advantage of testing the configuration of the logger? I remember extracting fields from the logger wasn't the easiest task but I could be wrong
😅 Feel free to open a follow-up issue if you'd like to keep this conversation going🙏 @bwil: The advantage is that we won't have to open more MRs like this one because the tests can catch when the log fields are wrong
😁 Yes, extracting fields from the logger is not straightforward, but with my proposal we would be checking the fields that the logger is created with, rather than trying to get them out of an already-initialized logger.