-
Notifications
You must be signed in to change notification settings - Fork 209
Description
Description
It would be useful to be able to reconfigure a Logfire object.
Right now, any call to .configure() needs to be aware of the full configuration for the logging and can't just update/reconfigure certain aspects. This can be problematic when needing to just update one aspect of the logger, like when testing.
For example, if I want to add a test exporter for tests
# app.py
import logfire
logfire.configure(
scrubbing=logfire.ScrubbingOptions()
)
def main():
logfire.info(...)# test.py
import logfire
from logfire.testing import SimpleSpanProcessor, TestExporter
from app import main
def test_scrubbing():
exporter = TestExporter()
logfire.configure(
scrubbing=logfire.ScrubbingOptions(),
additional_span_processors=[SimpleSpanProcessor(exporter)],
)
main()Here, Logire was already configured in app.py. I want to test my scrubber but I need to reconfigure it in the test. logfire.reconfigure would allow me to just pass additional_span_processors.
There is option of using capfire, but that has the inverse problem.
# test.py
import logfire
from logfire.testing import CaptureLogfire
from app import main
def test_scrubbing(capfire: CaptureLogfire):
exporter = TestExporter()
logfire.configure(
scrubbing=logfire.ScrubbingOptions(),
additional_span_processors=[SimpleSpanProcessor(exporter)],
)
main()This time, the capfire fixture has made a call to logfire.configure(), overwriting the configuration from app.py. In order to add the scrubbing back in, I also need to configure my own test exporter. logfire.reconfigure would allow me to just pass scrubbing.