Skip to content

Commit

Permalink
Merge pull request #200 from PolyJIT/f/adjust-logging
Browse files Browse the repository at this point in the history
utils/log: refactor logging & silence sqlalchemy.migrate logs
  • Loading branch information
simbuerg committed Jul 11, 2018
2 parents a4d4db3 + 2c37f53 commit 709db10
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions benchbuild/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
from benchbuild import settings


def configure_migrate_log():
migrate_log = logging.getLogger("migrate.versioning")
migrate_log.setLevel(logging.ERROR)
migrate_log.propagate = True


def configure_plumbum_log():
plumbum_format = logging.Formatter('$> %(message)s')
plumbum_hdl = logging.StreamHandler()
plumbum_hdl.setFormatter(plumbum_format)
plumbum_local = logging.getLogger("plumbum.local")
if settings.CFG["debug"].value():
plumbum_local.setLevel(logging.DEBUG)
plumbum_local.addHandler(plumbum_hdl)
plumbum_local.propagate = False


def configure():
"""Load logging configuration from our own defaults."""
log_levels = {
Expand All @@ -23,20 +40,14 @@ def configure():
details_hdl.setFormatter(details_format)
root_logger.addHandler(details_hdl)
else:
brief_format = logging.Formatter('%(message)s')
brief_format = logging.Formatter('%(name)s %(message)s')
console_hdl = logging.StreamHandler()
console_hdl.setFormatter(brief_format)
root_logger.addHandler(console_hdl)
root_logger.setLevel(log_levels[settings.CFG["verbosity"].value()])

plumbum_format = logging.Formatter('$> %(message)s')
plumbum_hdl = logging.StreamHandler()
plumbum_hdl.setFormatter(plumbum_format)
plumbum_local = logging.getLogger("plumbum.local")
if settings.CFG["debug"].value():
plumbum_local.setLevel(logging.DEBUG)
plumbum_local.addHandler(plumbum_hdl)
plumbum_local.propagate = False
configure_plumbum_log()
configure_migrate_log()


def set_defaults():
Expand Down

0 comments on commit 709db10

Please sign in to comment.