Skip to content

Commit

Permalink
Read loglevel from roam.config
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Nov 24, 2017
1 parent c38e1f5 commit 5d719bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/configmanager/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import roam.utils
from configmanager.ui.configmanagerdialog import ConfigManagerDialog

roam.utils.setup_logging(roamapp.profileroot)
roam.utils.setup_logging(roamapp.profileroot, roam.config.settings)

roamapp.app.setStyleSheet(roam.roam_style.appstyle())
dialog = ConfigManagerDialog(roamapp)
Expand Down
2 changes: 1 addition & 1 deletion src/roam/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import roam.mainwindow
import roam.utils

roam.utils.setup_logging(roamapp.profileroot)
roam.utils.setup_logging(roamapp.profileroot, roam.config.settings)

window = roam.mainwindow.MainWindow(roamapp)

Expand Down
10 changes: 8 additions & 2 deletions src/roam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
exception = logger.exception


def setup_logging(approot):
def setup_logging(approot, config=None):
"""
Setup the roam logger relative to the given approot folder.
:param approot: The folder to create the log folder in.
"""
if config is None:
config = {"loglevel": "INOF"}

try:
logpath = os.path.join(os.environ['ROAM_APPPATH'], 'log')
except KeyError:
Expand All @@ -44,7 +47,10 @@ def setup_logging(approot):
mode='at',
maxBytes=1000000,
backupCount=5)
filehandler.setLevel(logging.INFO)

levelname = config.get("loglevel", "INFO")
level = logging.getLevelName(levelname)
filehandler.setLevel(level)
filehandler.setFormatter(formater)

stream = logging.StreamHandler(stream=sys.stdout)
Expand Down

0 comments on commit 5d719bd

Please sign in to comment.