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

Configurable logging #686

Open
janosh opened this issue Oct 2, 2024 · 0 comments
Open

Configurable logging #686

janosh opened this issue Oct 2, 2024 · 0 comments
Labels
enhancement New feature or request ux User experience

Comments

@janosh
Copy link
Member

janosh commented Oct 2, 2024

run_locally allows toggling a python std lib logger

log: bool = True,

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)

@janosh janosh added enhancement New feature or request ux User experience labels Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ux User experience
Projects
None yet
Development

No branches or pull requests

1 participant