run_locally allows toggling a python std lib logger
whose settings are hard-coded in initialize_logger. would be great if run_locally accepted a list of custom handlers. we run DFT in containers on cloud infra and would like to send our logs to ElasticSearch which currently seems to require a lot of hackery
|
|
|
def initialize_logger(level: int = logging.INFO) -> logging.Logger: |
|
"""Initialize the default logger. |
|
|
|
Parameters |
|
---------- |
|
level |
|
The log level. |
|
|
|
Returns |
|
------- |
|
Logger |
|
A logging instance with customized formatter and handlers. |
|
""" |
|
import sys |
|
|
|
log = logging.getLogger("jobflow") |
|
log.setLevel(level) |
|
log.handlers = [] # reset logging handlers if they already exist |
|
|
|
fmt = logging.Formatter("%(asctime)s %(levelname)s %(message)s") |
|
screen_handler = logging.StreamHandler(stream=sys.stdout) |
|
screen_handler.setFormatter(fmt) |
|
log.addHandler(screen_handler) |
run_locallyallows toggling a python std lib loggerjobflow/src/jobflow/managers/local.py
Line 18 in 947072a
whose settings are hard-coded in
initialize_logger. would be great ifrun_locallyaccepted a list of custom handlers. we run DFT in containers on cloud infra and would like to send our logs to ElasticSearch which currently seems to require a lot of hackeryjobflow/src/jobflow/utils/log.py
Lines 5 to 28 in 947072a