Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable adding custom LogStasher fields from apps
I.e. allow apps to add their own custom fields in addition to those that `GovukJsonLogging` already adds. It looks like `LogStasher.add_custom_fields` can only be called one time, otherwise subsequent calls overwrite previous ones. We found this happening in the wild in the Content Store app, where `govuk_request_id` et al were missing from the Rails framework logs but present whenever the logger had been invoked directly from our own code. I am curious about the possibility of being able to add custom fields to both types of logs, together or separately, but the bug we're currently experiencing is just a conflict between two calls to `LogStasher.add_custom_fields`, so that's what I'm addressing. --- I've tried to add specs for this and failed. LogStasher seems to only load these settings inside of controllers, but adding a controller to the dummy Rails app in the `GovukJsonLogging` specs didn't magically solve the issue. I don't think a more full-blown Rails app would be out-of-place in this test suite, but without more confidence that introducing one would actually get my specs working, I'm reluctant to spend an unspecified amount of time bashing my head against that. I've manually tested this change locally with Content Store, both with and without its own custom field config.
- Loading branch information