Defaults added#26
Conversation
nhairs
left a comment
There was a problem hiding this comment.
Overall looks good.
I'm wondering if we should add something to the quick start docs.
Improves handling of optional packages by: - No importing them just to check if available - Raises a more specific type of error (and message) ### Test Plan - Run unit tests
# Conflicts: # docs/changelog.md
|
Haven't run black on the last change, I apologize. Should be good now. I'm receiving import errors on mypy, but those are unrelated (running on py3.13) where msgspec doesn't exist yet...? |
Yep that's fine - on CI we run it using 3.12 which I can see is passing 🎉 |
There was a problem hiding this comment.
I think we still need to add something to the "Quick start" docs, we also need to add to the doctstring change log.
~If I'm able to push to the branch I'll do these change myself to save on time. ~ I cannot push.
Could you add the following to docs/quickstart.md before the Static Fields section:
#### Default Fields
Default fields that are added to every log record prior to any other field can be set using the `default` argument.
```python
formatter = JsonFormatter(
defaults={"remote_ip": None}
)
# ...
logger.info("this overwrites the remote_ip field", extras={"remove_ip": "1.1.1.1"})
```And the following to the BaseFormatter docstring:
*Changed in 3.2*: `defaults` argument is no longer ignored.
|
Oh you managed to push it I see :-) Can we close this then? :D |
closes #24
Pretty simple. Two unit tests to check for a defaults parameter alone, and with a rename.