mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 01:31:08 +08:00
[cli] Fix issues with logging unescaped strings (#9960)
This commit is contained in:
@@ -102,8 +102,8 @@ def handle_boto_error(exc, msg, *args, **kwargs):
|
||||
cli_logger.error(*generic_message_args)
|
||||
cli_logger.newline()
|
||||
with cli_logger.verbatim_error_ctx("Boto3 error:"):
|
||||
cli_logger.verbose(vars(exc))
|
||||
cli_logger.error(exc)
|
||||
cli_logger.verbose("{}", str(vars(exc)))
|
||||
cli_logger.error("{}", str(exc))
|
||||
cli_logger.abort()
|
||||
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ class _CliLogger():
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self._print(_format_msg(cf.cornflowerBlue(msg), *args, **kwargs))
|
||||
self.print(cf.cornflowerBlue(msg), *args, **kwargs)
|
||||
|
||||
return self.indented()
|
||||
|
||||
@@ -252,7 +252,7 @@ class _CliLogger():
|
||||
|
||||
class VerbatimErorContextManager():
|
||||
def __enter__(self):
|
||||
cli_logger.error(cf.bold("!!! ") + msg, *args, **kwargs)
|
||||
cli_logger.error(cf.bold("!!! ") + "{}", msg, *args, **kwargs)
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
cli_logger.error(cf.bold("!!!"))
|
||||
@@ -267,6 +267,9 @@ class _CliLogger():
|
||||
|
||||
For other arguments, see `_format_msg`.
|
||||
"""
|
||||
if self.old_style:
|
||||
return
|
||||
|
||||
self._print(
|
||||
cf.cyan(key) + ": " + _format_msg(cf.bold(msg), *args, **kwargs))
|
||||
|
||||
@@ -299,27 +302,30 @@ class _CliLogger():
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self._print(_format_msg(cf.green(msg), *args, **kwargs))
|
||||
self.print(cf.green(msg), *args, **kwargs)
|
||||
|
||||
def warning(self, msg, *args, **kwargs):
|
||||
"""Prints a formatted warning message.
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self._print(_format_msg(cf.yellow(msg), *args, **kwargs))
|
||||
self.print(cf.yellow(msg), *args, **kwargs)
|
||||
|
||||
def error(self, msg, *args, **kwargs):
|
||||
"""Prints a formatted error message.
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
self._print(_format_msg(cf.red(msg), *args, **kwargs))
|
||||
self.print(cf.red(msg), *args, **kwargs)
|
||||
|
||||
def print(self, msg, *args, **kwargs):
|
||||
"""Prints a message.
|
||||
|
||||
For arguments, see `_format_msg`.
|
||||
"""
|
||||
if self.old_style:
|
||||
return
|
||||
|
||||
self._print(_format_msg(msg, *args, **kwargs))
|
||||
|
||||
def abort(self, msg=None, *args, **kwargs):
|
||||
|
||||
@@ -324,8 +324,8 @@ class SSHCommandRunner(CommandRunnerInterface):
|
||||
try:
|
||||
os.makedirs(self.ssh_control_path, mode=0o700, exist_ok=True)
|
||||
except OSError as e:
|
||||
cli_logger.warning(e) # todo: msg
|
||||
cli_logger.old_warning(logger, e)
|
||||
cli_logger.warning("{}", str(e)) # todo: msg
|
||||
cli_logger.old_warning(logger, "{}", str(e))
|
||||
|
||||
def run(self,
|
||||
cmd,
|
||||
|
||||
@@ -271,7 +271,8 @@ def teardown_cluster(config_file: str, yes: bool, workers_only: bool,
|
||||
port_forward=None,
|
||||
with_output=False)
|
||||
except Exception as e:
|
||||
cli_logger.verbose_error(e) # todo: add better exception info
|
||||
# todo: add better exception info
|
||||
cli_logger.verbose_error("{}", str(e))
|
||||
cli_logger.warning(
|
||||
"Exception occured when stopping the cluster Ray runtime "
|
||||
"(use -v to dump teardown exceptions).")
|
||||
|
||||
@@ -91,8 +91,9 @@ class NodeUpdater:
|
||||
"Setup command `{}` failed with exit code {}. stderr:",
|
||||
cf.bold(e.cmd), e.returncode)
|
||||
else:
|
||||
cli_logger.verbose_error(vars(e), _no_format=True)
|
||||
cli_logger.error(str(e)) # todo: handle this better somehow?
|
||||
cli_logger.verbose_error("{}", str(vars(e)))
|
||||
# todo: handle this better somehow?
|
||||
cli_logger.error("{}", str(e))
|
||||
# todo: print stderr here
|
||||
cli_logger.error("!!!")
|
||||
cli_logger.newline()
|
||||
@@ -282,7 +283,9 @@ class NodeUpdater:
|
||||
cmd_to_print = cf.bold(cmd)
|
||||
|
||||
cli_logger.print(
|
||||
cmd_to_print, _numbered=("()", i, total))
|
||||
"{}",
|
||||
cmd_to_print,
|
||||
_numbered=("()", i, total))
|
||||
|
||||
self.cmd_runner.run(cmd)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user