Skip to content

logging: Add handler param to basicConfig. #1023

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

greezybacon
Copy link
Contributor

CPython allows specifying a list of handlers in the initialization of logging with basicConfig(handlers=). This adds similar support but only with a single handler. It allows to initialize logging with a single, specialized handler.

CPython allows specifying a list of handlers in the initialization of
logging with basicConfig(handlers=<iterable>). This adds similar support
but only with a single handler. It allows to initialize logging with a
single, specialized handler.

Signed-off-by: Jared Hancock <jared@greezybacon.me>
@stinos
Copy link

stinos commented Jun 11, 2025

It seems like a small step to just support handlers then, such that the code should remains compatible with CPython?

@greezybacon
Copy link
Contributor Author

I could do that, yeah. My thought was that for an MCU more than one handler is unlikely, but I agree that compatibility means that everyone feels more comfortable using Micropython.

@Josverl
Copy link

Josverl commented Jun 12, 2025

I agree that handlers = [] is simpler to learn ,
it also means that adding
Logger.addHandler() makes more sense.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants