Log to terminal if glog is also doing so (#7868)

This commit is contained in:
mehrdadn
2020-04-10 16:41:21 -07:00
committed by GitHub
parent 9e31ee991a
commit 0b4e09da76
2 changed files with 14 additions and 16 deletions
+11 -15
View File
@@ -349,25 +349,21 @@ class Node:
raise FileExistsError(errno.EEXIST,
"No usable temporary filename found")
def new_log_files(self, name, redirect_output=True):
def new_log_files(self, name):
"""Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and false if stdout and stderr
should not be redirected.
If it is None, it will use the "redirect_output" Ray parameter.
Returns:
If redirect_output is true, this will return a tuple of two
file handles. The first is for redirecting stdout and the
second is for redirecting stderr.
If redirect_output is false, this will return a tuple
of two None objects.
A tuple of two file handles for redirecting (stdout, stderr).
"""
redirect_output = self._ray_params.redirect_output
if redirect_output is None:
redirect_output = self._ray_params.redirect_output
# Make the default behavior match that of glog.
redirect_output = os.getenv("GLOG_logtostderr") != "1"
if not redirect_output:
return None, None
@@ -471,7 +467,7 @@ class Node:
def start_reporter(self):
"""Start the reporter."""
stdout_file, stderr_file = self.new_log_files("reporter", True)
stdout_file, stderr_file = self.new_log_files("reporter")
process_info = ray.services.start_reporter(
self.redis_address,
stdout_file=stdout_file,
@@ -492,7 +488,7 @@ class Node:
fail to start the webui. Otherwise it will print a warning if
we fail to start the webui.
"""
stdout_file, stderr_file = self.new_log_files("dashboard", True)
stdout_file, stderr_file = self.new_log_files("dashboard")
self._webui_url, process_info = ray.services.start_dashboard(
require_webui,
self._ray_params.webui_host,
@@ -580,8 +576,8 @@ class Node:
def new_worker_redirected_log_file(self, worker_id):
"""Create new logging files for workers to redirect its output."""
worker_stdout_file, worker_stderr_file = (self.new_log_files(
"worker-" + ray.utils.binary_to_hex(worker_id), True))
worker_stdout_file, worker_stderr_file = (
self.new_log_files("worker-" + ray.utils.binary_to_hex(worker_id)))
return worker_stdout_file, worker_stderr_file
def start_worker(self):