You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using the library to write a custom logger and most of the things went smoothly. The only problem I can't find the solution in the documentation is how to modify the exception format (colors, text-decoration) that is given by default.
I would like, for example, to change the colors of excpetion messages, since when printed in other places it's sometimes hard to read due to the lack of contrast with the background. Is there any place I can find information on this?
My current formatter is configured like this:
defformatter(record):
"""Function that defines the format that should be used in the log messages, establishing colors, icons and text decorations """colors_dict= {
"DEBUG": "white",
"INFO": "white",
"SUCCESS": "green",
"WARNING": "yellow",
"ERROR": "red",
"CRITICAL": "red",
}
forlevel, colorincolors_dict.items():
logger.level(name=level, color=f"<bold><{color}>")
colored_message=format_message(record["message"])
escaped=colored_message.replace("{", "{{").replace("}", "}}")
return (
"{time:DD/MM/YYYY - HH:mm:ss} | "+"<level>{level:<9} </>| "+f"{escaped}\n"+"{exception}"
)
Any suggestions on how to make the formatter cleaner are also appreciated
The text was updated successfully, but these errors were encountered:
gabriel-tadeu-gt
changed the title
How can I customize the formatting of exceptions?
How can I customize exception formatting?
Apr 10, 2024
I've been using the library to write a custom logger and most of the things went smoothly. The only problem I can't find the solution in the documentation is how to modify the exception format (colors, text-decoration) that is given by default.
I would like, for example, to change the colors of excpetion messages, since when printed in other places it's sometimes hard to read due to the lack of contrast with the background. Is there any place I can find information on this?
My current formatter is configured like this:
Any suggestions on how to make the formatter cleaner are also appreciated
The text was updated successfully, but these errors were encountered: