Skip to content

add logging.addLevelName to add level mapping to logging, this way lo…#1232

Merged
Delgan merged 2 commits intoDelgan:masterfrom
yechielb2000:bugfix/level-mapping-logging
Nov 20, 2024
Merged

add logging.addLevelName to add level mapping to logging, this way lo…#1232
Delgan merged 2 commits intoDelgan:masterfrom
yechielb2000:bugfix/level-mapping-logging

Conversation

@yechielb2000
Copy link
Contributor

…gging will found my custom level name

closes this issue

@yechielb2000
Copy link
Contributor Author

Now, logging when the StandardSink creating the log record returns the actual level name:

import logging

from loguru import logger

logger.remove()

standard_formatter = logging.Formatter("%(levelname)s | %(levelno)d | %(message)s")
standard_handler = logging.StreamHandler()
standard_handler.setFormatter(standard_formatter)
logger.add(standard_handler, format="{message}")

logger.success("This is a success message")
# => SUCCESS | 25 | This is a success message

@Delgan Delgan merged commit 08e7ccc into Delgan:master Nov 20, 2024
@Delgan
Copy link
Owner

Delgan commented Nov 20, 2024

Looking good! Nice catch and thanks for the PR. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loguru Log Levels Not Fully Compatible with Python Logging's LogRecord

2 participants