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

[Data] Adding in better framework for substituting logging handlers #48056

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions python/ray/data/_internal/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
os.path.join(os.path.dirname(__file__), "logging.yaml")
)

# Dictionary of substitutions to be performed when using JSON mode. Handlers with names
# corresponding to keys will be replaced by those corresponding to values.
RAY_DATA_LOG_HANDLER_JSON_SUBSTITUTIONS = {"file": "file_json"}

# Env. variable to specify the encoding of the file logs when using the default config.
RAY_DATA_LOG_ENCODING_ENV_VAR_NAME = "RAY_DATA_LOG_ENCODING"

Expand Down Expand Up @@ -118,8 +122,12 @@ def _load_logging_config(config_path: str):
config = _load_logging_config(DEFAULT_CONFIG_PATH)
if log_encoding is not None and log_encoding.upper() == "JSON":
for logger in config["loggers"].values():
logger["handlers"].remove("file")
logger["handlers"].append("file_json")
for (
old_handler_name,
new_handler_name,
) in RAY_DATA_LOG_HANDLER_JSON_SUBSTITUTIONS.items():
logger["handlers"].remove(old_handler_name)
logger["handlers"].append(new_handler_name)

logging.config.dictConfig(config)

Expand Down
Loading