Skip to content
Advertisement

How to set a minimal logging level with loguru?

I would like to use a different logging level in development and production. To do so, I need early in my program to set the minimal level for logs to be triggered. The default is to output all severities:

JavaScript

There is a Changing the level of an existing handler section in the documentation, that states among others that

Once a handler has been added, it is actually not possible to update it. (…)

The most straightforward workaround is to remove() your handler and then re-add() it with the updated level parameter.

My problem is that I have not added anything, so there is nothing to remove. I also cannot modify log. So what should I do?

Advertisement

Answer

Like so:

JavaScript

More info.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement