Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning for invalid muscle_local_log_level in Python instance #306

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions libmuscle/python/libmuscle/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ def _set_remote_log_level(self) -> None:

Note that this also sets the global log level to this level
if it is currently higher, otherwise we still get no output.

"""
try:
log_level_str = self.get_setting('muscle_remote_log_level', 'str')
Expand Down Expand Up @@ -1175,26 +1174,26 @@ def _set_local_log_level(self) -> None:
It also attaches a FileHandler which outputs to a local file named
after the instance. This name can be overridden by the
--muscle-log-file command line option.

"""
try:
log_level_str = self.get_setting('muscle_local_log_level', 'str')
except KeyError:
# muscle_remote_log_level not set, do nothing and keep the default
return

try:
log_level = LogLevel[log_level_str.upper()]
if log_level is None:
_logger.warning(
('muscle_remote_log_level is set to {}, which is not a'
' valid log level. Please use one of DEBUG, INFO,'
' WARNING, ERROR, CRITICAL, or DISABLED').format(
log_level_str))
return

py_level = log_level.as_python_level()
logging.getLogger('libmuscle').setLevel(py_level)
logging.getLogger('ymmsl').setLevel(py_level)
except KeyError:
# muscle_remote_log_level not set, do nothing and keep the default
pass
_logger.warning(
('muscle_local_log_level is set to {}, which is not a'
' valid log level. Please use one of DEBUG, INFO,'
' WARNING, ERROR, CRITICAL, or DISABLED').format(
log_level_str))
return

py_level = log_level.as_python_level()
logging.getLogger('libmuscle').setLevel(py_level)
logging.getLogger('ymmsl').setLevel(py_level)

def __apply_overlay(self, message: Message) -> None:
"""Sets local overlay if we don't already have one.
Expand Down
Loading