Delgan / loguru

Python logging made (stupidly) simple

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RecordLevel lack of property “color”

main1015 opened this issue · comments

There are color properties when defining what Level is, but RecordLevel lacks the color property when you format the output logs. In the documentation
There is no color in the “level: The severity used to log the message name (default)”, no, icon. But with the default log output

This is because color has been deemed quite pointless within RecordLevel, since it cannot be formatted. Colors should be specified using markup tags like <blue>...</blue> and <level>...</level>. This allows for defining a scheme using various colors, not just the one of current level, which encompasses the common format of your logs. The record fields can be formatted with {level.name} and {level.icon}, but this would not map very naturally if applied to colors.

What exactly is your use case for accessing level color from a record?

This is my code:
1712472647152
Below is the output:
1712472667508
However, I deleted the own output of loguru and defined the output format by myself, so there is no way to set the output color:
1712472893143

Can you use the special "<level>...</level>" color markup in your custom format?

@Delgan
Thank you very much, I want this effect, I haven't read the document carefully before, sorry

No problem, I'm closing this ticket then, since it's resolved. 👍