Created
December 10, 2018 10:59
-
-
Save laurent-laporte-pro/3e9ae387d7813f5ab16877b390552b94 to your computer and use it in GitHub Desktop.
Python logger format compatible with PyCharm Ideolog plugin (IntelliJ Platform)
This file contains hidden or 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
# coding: utf-8 | |
import logging | |
#: Log format which gives you the date/time and the PID of the running process. | |
#: The level name is DEBUG, INFO, WARNING, ERROR or CRITICAL | |
#: This logger format is compatible with PyCharm Ideolog plugin (IntelliJ Platform). | |
LOG_FORMAT = "%(asctime)s [%(process)7d] %(levelname)8s - %(name)-30s - %(message)s" | |
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, filename="sample.log") | |
logging.debug(u"Hi every body!") | |
logging.info(u"Well, I happy to meet you.") | |
logging.info(u"Do you want a coffee?") | |
logging.warning(u"Make sure it is not too hot...") | |
logging.error(u"Ouch! You burn yourself!") | |
logging.critical(u"Help! He has a Heart attach!!") | |
# 2018-12-10 11:54:52,095 [ 11224] DEBUG - root - Hi every body! | |
# 2018-12-10 11:54:52,096 [ 11224] INFO - root - Well, I happy to meet you. | |
# 2018-12-10 11:54:52,096 [ 11224] INFO - root - Do you want a coffee? | |
# 2018-12-10 11:54:52,096 [ 11224] WARNING - root - Make sure it is not too hot... | |
# 2018-12-10 11:54:52,096 [ 11224] ERROR - root - Ouch! You burn yourself! | |
# 2018-12-10 11:54:52,098 [ 11224] CRITICAL - root - Help! He has a Heart attach!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment