-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from logsdail/customcommand_react
Adds 'custom' HPC option to React workflow.
- Loading branch information
Showing
7 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
import sys | ||
def set_logger(logger_name, warning_level = 1): | ||
|
||
""" | ||
A general purpose error handler for CARMM - sets the Logger object | ||
with a sensible set of defaults | ||
Args: | ||
logger_name: str | ||
Name of logger passed to get_logger | ||
warning_level: int | ||
Sets minimum-severity log message printed from lowest (0, DEBUG) to highest (4, CRITICAL) | ||
Returns: | ||
carmm_logger: logger | ||
Logger object to be used by other modules for error handling | ||
""" | ||
|
||
# Create dictionary for easy access debugs | ||
warning_lvls = {0: logging.DEBUG, 1: logging.INFO, 2: logging.WARNING, | ||
3: logging.ERROR, 4: logging.CRITICAL} | ||
|
||
# create logger | ||
logger = logging.getLogger(logger_name) | ||
logger.setLevel(warning_lvls[warning_level]) | ||
|
||
# create console handler and set level to debug | ||
ch = logging.StreamHandler(sys.stdout) | ||
ch.setLevel(warning_lvls[warning_level]) | ||
|
||
# create formatter | ||
# FULL FORMATTING | ||
#formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
# REDUCED FORMATTING | ||
formatter = logging.Formatter('%(levelname)s - %(message)s') | ||
|
||
# add formatter to ch | ||
ch.setFormatter(formatter) | ||
|
||
# add ch to logger | ||
logger.addHandler(ch) | ||
|
||
return logger | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
def test_set_logger(): | ||
from carmm.err_handler.logger_set import set_logger | ||
|
||
#TODO: MAKE THIS TEST ACTUALLY TEST CAPTURED OUTPUT | ||
|
||
logger = set_logger("test_logger", 0) | ||
|
||
logger.debug('test_set_logger test passed! DEBUG error correctly printed') | ||
|
||
test_set_logger() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters