Loguru: Changing a sink's minimum severity level afterwards

Created on 5 Apr 2019  路  1Comment  路  Source: Delgan/loguru

Hey,

I'm configuring my logger with a configuration dict which also sets the default level of my sinks to INFO. But at a later time, I'd like to be able to lower the level to DEBUG or one of my custom log levels for example.

As far as I'm aware of, there's no such way to do so at the moment. Is that correct?

question

Most helpful comment

You are correct. I think this is similar to what I discussed a few days ago here: https://github.com/Delgan/loguru/issues/51#issuecomment-478752897

There is actually no way to update a handler once it has been added. It is a deliberate choice in order to keep a minimal API.

You could remove() your INFO handler and re-add() it with a DEBUG level. Alternatively, you could use the filter argument to provide a function dynamically filtering logs based on their level. Check the comment I linked for some code samples, and tell me if that solves your issue. 馃憤

>All comments

You are correct. I think this is similar to what I discussed a few days ago here: https://github.com/Delgan/loguru/issues/51#issuecomment-478752897

There is actually no way to update a handler once it has been added. It is a deliberate choice in order to keep a minimal API.

You could remove() your INFO handler and re-add() it with a DEBUG level. Alternatively, you could use the filter argument to provide a function dynamically filtering logs based on their level. Check the comment I linked for some code samples, and tell me if that solves your issue. 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flybaozi picture flybaozi  路  4Comments

rightx2 picture rightx2  路  3Comments

lvar picture lvar  路  6Comments

jonathanhle picture jonathanhle  路  3Comments

ghost picture ghost  路  4Comments