Skip to content

Instantly share code, notes, and snippets.

@ustun
Created October 27, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ustun/a8cff6d4125179dbdc2bcb26d48f353a to your computer and use it in GitHub Desktop.
Save ustun/a8cff6d4125179dbdc2bcb26d48f353a to your computer and use it in GitHub Desktop.
import logging
import logging.config
def configure_logging():
LOG_DIR = "logs/"
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"formatters": {
"verbose": {
"format": "Logger: %(name)s %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d [%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
},
"simple": {"format": "%(levelname)s %(asctime)s %(message)s"},
"only_message": {"format": "%(message)s"},
},
"handlers": {
"file": {
"level": "INFO",
"class": "logging.FileHandler",
"filename": LOG_DIR + "logs.log",
"formatter": "verbose",
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "simple",
},
},
"root": {"level": "DEBUG", "handlers": ["file", "console"]},
}
logging.config.dictConfig(LOGGING)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment