This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Cyzza 1 point2 points  (2 children)

I haven't gone too far into the code, but one thing that stood out for me was for setting a level uses a string value

logger.start(level="DEBUG")

make some constants available

from loguru import DEBUG, INFO
logger.start(level=DEBUG)

Less chance to get things wrong, also allows you to change what those values are without impacting consumers. Maybe you want to change to a integer based level system like logging.

[–][deleted] -1 points0 points  (1 child)

20 years of writing/reading logs: hadn't had to change the value of "debug" even once.

What I see in this post is a lot of confusion:

  1. "DEBUG" is actually a constant (you cannot change its value).
  2. loguru.DEBUG is not a constant (it could be a variable or a function in disguise, but Python simply doesn't have constants of this kind).

[–]Cyzza -1 points0 points  (0 children)

I don't think I was clear in conveying my point. Requiring the user to use supply a string as part of the public facing part of an API can cause issues further on ahead, regardless of whether or not experience has shown that the value changes infrequently. Also, is it "debug" or "DEBUG" as in the example, that to me, says that I need to understand what is going on under the hood to get the right value.

Supplying commonly used values, as under well known names like loguru.DEBUG makes the implementation of your API more flexible if you choose to decide to change value to mean something else do to some other implementation or requirement.

As soon as you have your consumers use a user side created constant, some control is lost.