-
Notifications
You must be signed in to change notification settings - Fork 0
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 #75 from oele-isis-vanderbilt/dev_branch
Bug Patch
- Loading branch information
Showing
48 changed files
with
1,237 additions
and
713 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
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
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,21 @@ | ||
# Built-in Import | ||
from typing import List, Optional | ||
import logging | ||
import os | ||
|
||
# Internal Imports | ||
from ._logger import LOGGING_CONFIG | ||
|
||
|
||
def debug(loggers: Optional[List[str]] = None): | ||
|
||
# Not provided, then get all | ||
if type(loggers) == type(None): | ||
loggers = [x for x in LOGGING_CONFIG["loggers"]] | ||
|
||
assert loggers != None | ||
|
||
# Change env variable and configurations | ||
os.environ["CHIMERAPY_DEBUG_LOGGERS"] = os.pathsep.join(loggers) | ||
for logger_name in loggers: | ||
logging.getLogger(logger_name).setLevel(logging.DEBUG) |
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,68 @@ | ||
# Setup the logging for the library | ||
# References: | ||
# https://docs.python-guide.org/writing/logging/ | ||
# https://stackoverflow.com/questions/13649664/how-to-use-logging-with-pythons-fileconfig-and-configure-the-logfile-filename | ||
import logging.config | ||
import os | ||
|
||
LOGGING_CONFIG = { | ||
"version": 1, | ||
"disable_existing_loggers": True, | ||
"formatters": { | ||
"standard": { | ||
"format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s", | ||
"datefmt": "%Y-%m-%d %H:%M:%S", | ||
}, | ||
}, | ||
"handlers": { | ||
"console": { | ||
"level": "INFO", | ||
"formatter": "standard", | ||
"class": "logging.StreamHandler", | ||
"stream": "ext://sys.stdout", # Default is stderr | ||
}, | ||
"datagram": { | ||
"level": "DEBUG", | ||
"formatter": "standard", | ||
"class": "logging.handlers.DatagramHandler", | ||
"host": "127.0.0.1", | ||
"port": 5555, | ||
}, | ||
}, | ||
"loggers": { | ||
"chimerapy": { | ||
"handlers": ["console"], | ||
"level": "INFO", | ||
"propagate": True, | ||
}, | ||
"chimerapy-networking": { | ||
"handlers": ["console"], | ||
"level": "INFO", | ||
"propagate": True, | ||
}, | ||
"chimerapy-subprocess": { | ||
"handlers": ["datagram"], | ||
"level": "INFO", | ||
"propagate": True, | ||
}, | ||
}, | ||
} | ||
|
||
# Setup the logging configuration | ||
def setup(): | ||
|
||
# Setting up the configureation | ||
logging.config.dictConfig(LOGGING_CONFIG) | ||
|
||
|
||
def getLogger(name: str): | ||
|
||
# Get the logging | ||
logger = logging.getLogger(name) | ||
|
||
# Ensure that the configuration is set | ||
debug_loggers = os.environ.get("CHIMERAPY_DEBUG_LOGGERS", "").split(os.pathsep) | ||
if name in debug_loggers: | ||
logger.setLevel(logging.DEBUG) | ||
|
||
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
Oops, something went wrong.