Last active
August 31, 2017 22:12
-
-
Save martisak/cf318a9ec4c1d0bc1446bc3a930c105e to your computer and use it in GitHub Desktop.
Colored logs in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from util import logger | |
if __name__ == "__main__": | |
logger.info("Main just started") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import colorlog | |
format = '%(log_color)s%(asctime)15s %(name)15s %(levelname)10s - %(message)s' | |
handler = colorlog.StreamHandler() | |
handler.setFormatter(colorlog.ColoredFormatter( | |
format, datefmt="%y%m%d %H:%M:%S")) | |
logger = colorlog.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
logger.addHandler(handler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment