Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaults parameter is ignored #24

Closed
bharel opened this issue Aug 27, 2024 · 3 comments · Fixed by #26
Closed

Defaults parameter is ignored #24

bharel opened this issue Aug 27, 2024 · 3 comments · Fixed by #26
Labels
enhancement New feature or request

Comments

@bharel
Copy link
Contributor

bharel commented Aug 27, 2024

The defaults parameter that Logging.Formatter takes is ignored. We can make it work 😄

I can submit a patch :-)

@nhairs
Copy link
Owner

nhairs commented Aug 27, 2024

Hi @bharel,

I'm not opposed to giving the defaults argument a purpose, but what purpose would that be?

Keep in mind that we already have the static_fields parameter which is not going away any time soon as I won't break backwards compatibility without good reason.

@bharel
Copy link
Contributor Author

bharel commented Aug 28, 2024

Exactly the same purpose that it has in the standard library - provide a default value for optional fields.

Atm if a field doesn't exist it is returned as null.

Static fields are not doing the same thing - they always exist and override the other values.

@nhairs
Copy link
Owner

nhairs commented Aug 28, 2024

Okay I think I understand what you're getting at.

Essentially from the interactions of parsing required fields, renaming fields, and the actual fields on a log message it's possible that a field becomes None because of a missing value.

Which means what I think you're proposing is that we use the defaults dict to provide backup values for any field.

In which case I'd be happy to accept a patch :) In case you haven't seen it you can find the contributing guidelines here

@nhairs nhairs added the enhancement New feature or request label Aug 28, 2024
@bharel bharel mentioned this issue Sep 12, 2024
nhairs added a commit that referenced this issue Nov 10, 2024
closes #24 

Uses `defaults` argument to prepopulate fields on records.

### Test Plan
Unit tests

---------

Co-authored-by: Nicholas Hairs <info@nicholashairs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants