4

I have just started using the coloredlogs package in Python. I am using the version 15.0. I can see that my message changes color depending on its log level (info, debug, warning e.t.c.). However, the other parts of the message remain the same color as shown below:

enter image description here

The code I used for this is below:

import coloredlogs, logging

# Create a logger object.
logger = logging.getLogger("main")

# If you don't want to see log messages from libraries, you can pass a
# specific logger object to the install() function. In this case only log
# messages originating from that logger will show up on the terminal.
coloredlogs.install(level='DEBUG', logger=logger, fmt='%(name)s - %(levelname)s - %(message)s')

# Some examples.
logger.debug("this is a debugging message")
logger.info("this is an informational message")
logger.warning("this is a warning message")
logger.error("this is an error message")
logger.critical("this is a critical message")

1 Answer 1

1

Try logger = logging.getLogger(__name__)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.