logger: use write with \r\n instead of writeln

The device manager will set tty or pty to raw mode, all the `\n` will
be LF without CR, which makes the output difficult to read.

This commit solves it by using `write` with `\r\n` instead of
`writeln`, which can print CR and LF explicitly.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
This commit is contained in:
Yu Li 2023-05-31 16:33:47 +08:00 committed by Bo Chen
parent ce0f30bb54
commit 499989fb17

View File

@ -100,9 +100,9 @@ impl log::Log for Logger {
let duration = now.duration_since(self.start);
if record.file().is_some() && record.line().is_some() {
writeln!(
write!(
*(*(self.output.lock().unwrap())),
"cloud-hypervisor: {:.6?}: <{}> {}:{}:{} -- {}",
"cloud-hypervisor: {:.6?}: <{}> {}:{}:{} -- {}\r\n",
duration,
std::thread::current().name().unwrap_or("anonymous"),
record.level(),
@ -111,9 +111,9 @@ impl log::Log for Logger {
record.args()
)
} else {
writeln!(
write!(
*(*(self.output.lock().unwrap())),
"cloud-hypervisor: {:.6?}: <{}> {}:{} -- {}",
"cloud-hypervisor: {:.6?}: <{}> {}:{} -- {}\r\n",
duration,
std::thread::current().name().unwrap_or("anonymous"),
record.level(),