micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

logging: Add `handler` param to `basicConfig`.

Open greezybacon opened this issue 7 months ago • 3 comments

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.

greezybacon avatar Jun 11 '25 12:06 greezybacon

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

stinos avatar Jun 11 '25 13:06 stinos

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.

greezybacon avatar Jun 11 '25 13:06 greezybacon

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

Josverl avatar Jun 12 '25 10:06 Josverl