Skip to content

Commit

Permalink
Reformatted and added color to logger messages. (#252)
Browse files Browse the repository at this point in the history
Closes #248 

Added color to logging and converted some info messages to debug.

added colors and cleaned up logger

corrected formatting

added to dependencies

reverted message log level change

added debug format

debug logging format now works

flake8 fix
  • Loading branch information
ben-bay authored and FrankD412 committed May 28, 2022
1 parent 6446fb4 commit 803b392
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions maestrowf/datastructures/core/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def __init__(self, name, description,
self._out_path = out_path
self._meta_path = os.path.join(out_path, "meta")

LOGGER.info("OUTPUT_PATH = %s", out_path)
LOGGER.debug("OUTPUT_PATH = %s", out_path)
# Flag the study as not having been set up and add the source node.
self._issetup = False
self.is_configured = False
Expand Down Expand Up @@ -378,7 +378,7 @@ def walk_study(self, src=SOURCE):
def setup_workspace(self):
"""Set up the study's main workspace directory."""
try:
LOGGER.info("Setting up study workspace in '%s'", self._out_path)
LOGGER.debug("Setting up study workspace in '%s'", self._out_path)
create_parentdir(self._out_path)
except Exception as e:
LOGGER.error(e.args)
Expand All @@ -388,7 +388,7 @@ def setup_environment(self):
"""Set up the environment by acquiring outside dependencies."""
# Set up the environment if it hasn't been already.
if not self.environment.is_set_up:
LOGGER.info("Environment is setting up.")
LOGGER.debug("Environment is setting up.")
self.environment.acquire_environment()

def configure_study(self, submission_attempts=1, restart_limit=1,
Expand Down
2 changes: 1 addition & 1 deletion maestrowf/datastructures/core/studyenvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def acquire_environment(self):
LOGGER.info("Environment already set up. Returning.")
return

LOGGER.info("Acquiring dependencies")
LOGGER.debug("Acquiring dependencies")
for dependency, value in self.dependencies.items():
LOGGER.info("Acquiring -- %s", dependency)
value.acquire(substitutions=self.substitutions.values())
Expand Down
6 changes: 5 additions & 1 deletion maestrowf/maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ def main():

# If we have requested to log stdout, set it up to be logged.
if args.logstdout:
LOG_UTIL.configure(LFORMAT, args.debug_lvl)
if args.debug_lvl == 1:
lformat = DEBUG_FORMAT
else:
lformat = LFORMAT
LOG_UTIL.configure(lformat, args.debug_lvl)

LOGGER.info("INFO Logging Level -- Enabled")
LOGGER.warning("WARNING Logging Level -- Enabled")
Expand Down
5 changes: 4 additions & 1 deletion maestrowf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,17 @@ def __init__(self, logger):
"""
self._logger = logger

def configure(self, log_format, log_lvl=2):
def configure(self, log_format, log_lvl=2, colors=True):
"""
Configures the general logging facility.
:param log_format: String containing the desired logging format.
:param log_lvl: Integer level (1-5) to set the logger to.
"""
logging.basicConfig(level=self.map_level(log_lvl), format=log_format)
if colors:
coloredlogs.install(level=self.map_level(log_lvl),
logger=self._logger, fmt=log_format)

def add_stream_handler(self, log_format, log_lvl=2):
"""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tabulate
enum34; python_version<'3.4'
dill
jsonschema>=3.2.0
coloredlogs
-e .

fabric
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"enum34 ; python_version<'3.4'",
"dill",
"jsonschema>=3.2.0",
"coloredlogs",
],
extras_require={},
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 803b392

Please sign in to comment.