Delgan / loguru

Python logging made (stupidly) simple
MIT License
19.84k stars 697 forks source link

TypeError: Level 'TRACE' already exists, you can't update its severity no #275

Closed shmilylty closed 4 years ago

shmilylty commented 4 years ago

loguru 0.5.0

Traceback (most recent call last):
  File "D:/Tools/PenetrationTesting/2.Intelligence_Gathering/domain/OneForAll/oneforall.py", line 15, in <module>
    import dbexport
  File "D:\Tools\PenetrationTesting\2.Intelligence_Gathering\domain\OneForAll\dbexport.py", line 13, in <module>
    from common import utils
  File "D:\Tools\PenetrationTesting\2.Intelligence_Gathering\domain\OneForAll\common\utils.py", line 21, in <module>
    from config.log import logger
  File "D:\Tools\PenetrationTesting\2.Intelligence_Gathering\domain\OneForAll\config\log.py", line 26, in <module>
    logger.level(name='TRACE', no=5, color='<cyan><bold>', icon='✏️')
  File "C:\Users\pentest\.virtualenvs\OneForAll-4zkd7hGI\lib\site-packages\loguru\_logger.py", line 1516, in level
    raise TypeError("Level '%s' already exists, you can't update its severity no" % name)
TypeError: Level 'TRACE' already exists, you can't update its severity no

my code: https://github.com/shmilylty/OneForAll/blob/master/config/log.py#L26

Delgan commented 4 years ago

It was decided after discussions that the severity of a level should not be changed. You can remove no=5, no=10 and no=40 for levels "TRACE", "DEBUG" and "ERROR" and it will work fine.

Maybe I could update Loguru so that if the no is equal to the already configured severity, it does not raise an exception.

ioanfuse commented 2 months ago

Maybe I could update Loguru so that if the no is equal to the already configured severity, it does not raise an exception.

@Delgan is that on the roadmap?

Delgan commented 3 weeks ago

is that on the roadmap?

I'm not sure. I think the intent is wrong anyway. Users should not provide any no value when updating an existing level. It helps catching the problem earlier, rather than silently ignoring an invalid usage. In particular, it prevents the user from facing an unexpected error later on just because he changed the no value in the logger configuration. It would be surprising that logger.level("TRACE", no=5) works but not logger.level("TRACE", no=6).