Skip to content

Commit 2f5c5d8

Browse files
authored
[Core] Rename ray_log_filepath, ray_err_log_filepath to stdout_filepath, stderr_filepath (#51341)
Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
1 parent 3e03ddf commit 2f5c5d8

File tree

5 files changed

+45
-57
lines changed

5 files changed

+45
-57
lines changed

python/ray/_private/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,8 @@ def start_gcs_server(self):
12041204
process_info = ray._private.services.start_gcs_server(
12051205
self.redis_address,
12061206
log_dir=self._logs_dir,
1207-
ray_log_filepath=stdout_log_fname,
1208-
ray_err_log_filepath=stderr_log_fname,
1207+
stdout_filepath=stdout_log_fname,
1208+
stderr_filepath=stderr_log_fname,
12091209
session_name=self.session_name,
12101210
redis_username=self._ray_params.redis_username,
12111211
redis_password=self._ray_params.redis_password,
@@ -1277,8 +1277,8 @@ def start_raylet(
12771277
dashboard_agent_listen_port=self._ray_params.dashboard_agent_listen_port,
12781278
use_valgrind=use_valgrind,
12791279
use_profiler=use_profiler,
1280-
ray_log_filepath=stdout_log_fname,
1281-
ray_err_log_filepath=stderr_log_fname,
1280+
stdout_filepath=stdout_log_fname,
1281+
stderr_filepath=stderr_log_fname,
12821282
huge_pages=self._ray_params.huge_pages,
12831283
fate_share=self.kernel_fate_share,
12841284
socket_to_use=None,

python/ray/_private/services.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,8 @@ def get_address(redis_address):
14431443
def start_gcs_server(
14441444
redis_address: str,
14451445
log_dir: str,
1446-
ray_log_filepath: Optional[str],
1447-
ray_err_log_filepath: Optional[str],
1446+
stdout_filepath: Optional[str],
1447+
stderr_filepath: Optional[str],
14481448
session_name: str,
14491449
redis_username: Optional[str] = None,
14501450
redis_password: Optional[str] = None,
@@ -1459,10 +1459,10 @@ def start_gcs_server(
14591459
Args:
14601460
redis_address: The address that the Redis server is listening on.
14611461
log_dir: The path of the dir where gcs log files are created.
1462-
ray_log_filepath: The file path to dump gcs server log, which is
1463-
written via `RAY_LOG`. If None, logs will be sent to stdout.
1464-
ray_err_log_filepath: The file path to dump gcs server error log, which is
1465-
written via `RAY_LOG`. If None, logs will be sent to stderr.
1462+
stdout_filepath: The file path to dump gcs server stdout.
1463+
If None, stdout is not redirected.
1464+
stderr_filepath: The file path to dump gcs server stderr.
1465+
If None, stderr is not redirected.
14661466
session_name: The session name (cluster id) of this cluster.
14671467
redis_username: The username of the Redis server.
14681468
redis_password: The password of the Redis server.
@@ -1488,10 +1488,10 @@ def start_gcs_server(
14881488
f"--ray-commit={ray.__commit__}",
14891489
]
14901490

1491-
if ray_log_filepath:
1492-
command += [f"--ray_log_filepath={ray_log_filepath}"]
1493-
if ray_err_log_filepath:
1494-
command += [f"--ray_err_log_filepath={ray_err_log_filepath}"]
1491+
if stdout_filepath:
1492+
command += [f"--stdout_filepath={stdout_filepath}"]
1493+
if stderr_filepath:
1494+
command += [f"--stderr_filepath={stderr_filepath}"]
14951495

14961496
if redis_address:
14971497
redis_ip_address, redis_port, enable_redis_ssl = get_address(redis_address)
@@ -1507,11 +1507,11 @@ def start_gcs_server(
15071507
command += [f"--redis_password={redis_password}"]
15081508

15091509
stdout_file = None
1510-
if ray_log_filepath:
1510+
if stdout_filepath:
15111511
stdout_file = open(os.devnull, "w")
15121512

15131513
stderr_file = None
1514-
if ray_err_log_filepath:
1514+
if stderr_filepath:
15151515
stderr_file = open(os.devnull, "w")
15161516

15171517
process_info = start_ray_process(
@@ -1557,8 +1557,8 @@ def start_raylet(
15571557
runtime_env_agent_port: Optional[int] = None,
15581558
use_valgrind: bool = False,
15591559
use_profiler: bool = False,
1560-
ray_log_filepath: Optional[str] = None,
1561-
ray_err_log_filepath: Optional[str] = None,
1560+
stdout_filepath: Optional[str] = None,
1561+
stderr_filepath: Optional[str] = None,
15621562
huge_pages: bool = False,
15631563
fate_share: Optional[bool] = None,
15641564
socket_to_use: Optional[int] = None,
@@ -1612,10 +1612,10 @@ def start_raylet(
16121612
of valgrind. If this is True, use_profiler must be False.
16131613
use_profiler: True if the raylet should be started inside
16141614
a profiler. If this is True, use_valgrind must be False.
1615-
ray_log_filepath: The file path to dump raylet log, which is
1616-
written via `RAY_LOG`. If None, logs will be sent to stdout.
1617-
ray_err_log_filepath: The error file path to dump raylet log, which is
1618-
written via `RAY_LOG`. If None, logs will be sent to stderr.
1615+
stdout_filepath: The file path to dump raylet stdout.
1616+
If None, stdout is not redirected.
1617+
stderr_filepath: The file path to dump raylet stderr.
1618+
If None, stderr is not redirected.
16191619
tracing_startup_hook: Tracing startup hook.
16201620
max_bytes: Log rotation parameter. Corresponding to
16211621
RotatingFileHandler's maxBytes.
@@ -1769,7 +1769,7 @@ def start_raylet(
17691769
f"--gcs-address={gcs_address}",
17701770
f"--cluster-id-hex={cluster_id}",
17711771
]
1772-
if ray_log_filepath is None and ray_err_log_filepath is None:
1772+
if stdout_filepath is None and stderr_filepath is None:
17731773
# If not redirecting logging to files, unset log filename.
17741774
# This will cause log records to go to stderr.
17751775
dashboard_agent_command.append("--logging-filename=")
@@ -1833,10 +1833,10 @@ def start_raylet(
18331833
f"--cluster-id={cluster_id}",
18341834
]
18351835

1836-
if ray_log_filepath:
1837-
command.append(f"--ray_log_filepath={ray_log_filepath}")
1838-
if ray_err_log_filepath:
1839-
command.append(f"--ray_err_log_filepath={ray_err_log_filepath}")
1836+
if stdout_filepath:
1837+
command.append(f"--stdout_filepath={stdout_filepath}")
1838+
if stderr_filepath:
1839+
command.append(f"--stderr_filepath={stderr_filepath}")
18401840

18411841
if is_head_node:
18421842
command.append("--head")
@@ -1866,11 +1866,11 @@ def start_raylet(
18661866
)
18671867

18681868
stdout_file = None
1869-
if ray_log_filepath:
1869+
if stdout_filepath:
18701870
stdout_file = open(os.devnull, "w")
18711871

18721872
stderr_file = None
1873-
if ray_err_log_filepath:
1873+
if stderr_filepath:
18741874
stderr_file = open(os.devnull, "w")
18751875

18761876
process_info = start_ray_process(

src/ray/gcs/gcs_server/gcs_server_main.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,8 @@ DEFINE_string(redis_address, "", "The ip address of redis.");
3131
DEFINE_bool(redis_enable_ssl, false, "Use tls/ssl in redis connection.");
3232
DEFINE_int32(redis_port, -1, "The port of redis.");
3333
DEFINE_string(log_dir, "", "The path of the dir where log files are created.");
34-
DEFINE_string(ray_log_filepath,
35-
"",
36-
"The log filepath to dump gcs server log, which is written via `RAY_LOG`.");
37-
DEFINE_string(
38-
ray_err_log_filepath,
39-
"",
40-
"The filepath to dump gcs server error log, which is written via `RAY_LOG`.");
34+
DEFINE_string(stdout_filepath, "", "The filepath to dump gcs server stdout.");
35+
DEFINE_string(stderr_filepath, "", "The filepath to dump gcs server stderr.");
4136
DEFINE_int32(gcs_server_port, 0, "The port of gcs server.");
4237
DEFINE_int32(metrics_agent_port, -1, "The port of metrics agent.");
4338
DEFINE_string(config_list, "", "The config list of raylet.");
@@ -53,19 +48,19 @@ DEFINE_string(ray_commit, "", "The commit hash of Ray.");
5348
int main(int argc, char *argv[]) {
5449
gflags::ParseCommandLineFlags(&argc, &argv, true);
5550

56-
if (!FLAGS_ray_log_filepath.empty()) {
51+
if (!FLAGS_stdout_filepath.empty()) {
5752
ray::StreamRedirectionOption stdout_redirection_options;
58-
stdout_redirection_options.file_path = FLAGS_ray_log_filepath;
53+
stdout_redirection_options.file_path = FLAGS_stdout_filepath;
5954
stdout_redirection_options.rotation_max_size =
6055
ray::RayLog::GetRayLogRotationMaxBytesOrDefault();
6156
stdout_redirection_options.rotation_max_file_count =
6257
ray::RayLog::GetRayLogRotationBackupCountOrDefault();
6358
ray::RedirectStdout(stdout_redirection_options);
6459
}
6560

66-
if (!FLAGS_ray_err_log_filepath.empty()) {
61+
if (!FLAGS_stderr_filepath.empty()) {
6762
ray::StreamRedirectionOption stderr_redirection_options;
68-
stderr_redirection_options.file_path = FLAGS_ray_err_log_filepath;
63+
stderr_redirection_options.file_path = FLAGS_stderr_filepath;
6964
stderr_redirection_options.rotation_max_size =
7065
ray::RayLog::GetRayLogRotationMaxBytesOrDefault();
7166
stderr_redirection_options.rotation_max_file_count =

src/ray/raylet/main.cc

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,8 @@ DEFINE_string(native_library_path,
7474
DEFINE_string(temp_dir, "", "Temporary directory.");
7575
DEFINE_string(session_dir, "", "The path of this ray session directory.");
7676
DEFINE_string(log_dir, "", "The path of the dir where log files are created.");
77-
DEFINE_string(
78-
ray_log_filepath,
79-
"",
80-
"The filename to dump raylet log on stdout, which is written via `RAY_LOG`.");
81-
DEFINE_string(
82-
ray_err_log_filepath,
83-
"",
84-
"The filename to dump raylet error log on stderr, which is written via `RAY_LOG`.");
77+
DEFINE_string(stdout_filepath, "", "The filepath to dump raylet stdout.");
78+
DEFINE_string(stderr_filepath, "", "The filepath to dump raylet stderr.");
8579
DEFINE_string(resource_dir, "", "The path of this ray resource directory.");
8680
DEFINE_int32(ray_debugger_external, 0, "Make Ray debugger externally accessible.");
8781
// store options
@@ -136,19 +130,19 @@ absl::flat_hash_map<std::string, std::string> parse_node_labels(
136130
int main(int argc, char *argv[]) {
137131
gflags::ParseCommandLineFlags(&argc, &argv, true);
138132

139-
if (!FLAGS_ray_log_filepath.empty()) {
133+
if (!FLAGS_stdout_filepath.empty()) {
140134
ray::StreamRedirectionOption stdout_redirection_options;
141-
stdout_redirection_options.file_path = FLAGS_ray_log_filepath;
135+
stdout_redirection_options.file_path = FLAGS_stdout_filepath;
142136
stdout_redirection_options.rotation_max_size =
143137
ray::RayLog::GetRayLogRotationMaxBytesOrDefault();
144138
stdout_redirection_options.rotation_max_file_count =
145139
ray::RayLog::GetRayLogRotationBackupCountOrDefault();
146140
ray::RedirectStdout(stdout_redirection_options);
147141
}
148142

149-
if (!FLAGS_ray_err_log_filepath.empty()) {
143+
if (!FLAGS_stderr_filepath.empty()) {
150144
ray::StreamRedirectionOption stderr_redirection_options;
151-
stderr_redirection_options.file_path = FLAGS_ray_err_log_filepath;
145+
stderr_redirection_options.file_path = FLAGS_stderr_filepath;
152146
stderr_redirection_options.rotation_max_size =
153147
ray::RayLog::GetRayLogRotationMaxBytesOrDefault();
154148
stderr_redirection_options.rotation_max_file_count =
@@ -167,8 +161,8 @@ int main(int argc, char *argv[]) {
167161
ray::RayLog::ShutDownRayLog,
168162
/*app_name=*/argv[0],
169163
ray::RayLogLevel::INFO,
170-
/*ray_log_filepath=*/"",
171-
/*ray_err_log_filepath=*/"",
164+
/*log_filepath=*/"",
165+
/*err_log_filepath=*/"",
172166
/*log_rotation_max_size=*/0,
173167
/*log_rotation_file_num=*/1);
174168

src/ray/util/logging.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ void RayLog::InitLogFormat() {
382382
log_rotation_file_num_ = log_rotation_file_num;
383383

384384
// All the logging sinks to add.
385-
// One for file/stdout, another for stderr.
386385
std::array<spdlog::sink_ptr, 2> sinks; // Intentionally no initialization.
387386

388387
auto level = GetMappedSeverity(severity_threshold_);
@@ -397,7 +396,7 @@ void RayLog::InitLogFormat() {
397396
}
398397
}
399398

400-
// Set sink for stdout.
399+
// Set sink for logs above the user defined level.
401400
if (!log_filepath.empty()) {
402401
// Sink all log stuff to default file logger we defined here. We may need
403402
// multiple sinks for different files or loglevel.
@@ -424,7 +423,7 @@ void RayLog::InitLogFormat() {
424423
sinks[0] = std::move(console_sink);
425424
}
426425

427-
// Set sink for stderr.
426+
// Set sink for error logs.
428427
if (!err_log_filepath.empty()) {
429428
spdlog::sink_ptr err_sink;
430429
if (log_rotation_max_size_ == 0) {

0 commit comments

Comments
 (0)