Created
July 24, 2018 18:55
-
-
Save senaps/93651829b536ab19836ca72ba22140d4 to your computer and use it in GitHub Desktop.
logging boierplate this module should be included in the project and be used as the logger mechanism
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 sys | |
import logging | |
# handlers = { | |
# 'stream': logging.StreamHandler(sys.stdout), | |
# 'errstream': logging.StreamHandler(sys.stderr), | |
# 'file': logging.FileHandler, | |
# 'null': logging.NullHandler, | |
# 'rotatefile': logging.handlers.RotatingFileHandler, | |
# 'syslog': logging.handlers.SysLogHandler, | |
# } | |
def make_logger(): | |
"""create the logging object | |
:return: | |
""" | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
handler = logging.StreamHandler(sys.stdout) | |
handler.setFormatter( | |
logging.Formatter( | |
'[%(asctime)s] %(levelname)s in %(module)s: %(message)s')) | |
logger.addHandler(handler) | |
return logger | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment