Fix logger initialization (#27238)

This commit is contained in:
Eric Liang 2022-07-29 10:55:15 -07:00 committed by GitHub
parent 545c51609f
commit 467430dd55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View file

@ -1165,7 +1165,7 @@ def init(
arguments is passed in.
"""
if configure_logging:
setup_logger(logging_level, logging_format)
setup_logger(logging_level, logging_format or ray_constants.LOGGER_FORMAT)
# Parse the hidden options:
_enable_object_reconstruction: bool = kwargs.pop(
@ -1192,8 +1192,6 @@ def init(
_node_name: str = kwargs.pop("_node_name", None)
# Fix for https://github.com/ray-project/ray/issues/26729
_skip_env_hook: bool = kwargs.pop("_skip_env_hook", False)
if not logging_format:
logging_format = ray_constants.LOGGER_FORMAT
# If available, use RAY_ADDRESS to override if the address was left
# unspecified, or set to "auto" in the call to init

View file

@ -14,6 +14,21 @@ from ray._private.test_utils import (
)
def test_logger_config():
script = """
import ray
ray.init(num_cpus=1)
"""
proc = run_string_as_driver_nonblocking(script)
out_str = proc.stdout.read().decode("ascii")
err_str = proc.stderr.read().decode("ascii")
print(out_str, err_str)
assert "INFO worker.py:" in err_str, err_str
@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.")
def test_spill_logs():
script = """