Skip to content

Commit 5fb1ccb

Browse files
committed
Do not use buffered writers to write lines to the log file
When tailing the log file, we do not expect any buffering as the lines get written.
1 parent e9f047b commit 5fb1ccb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ldk-server/src/util/logger.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use log::{Level, LevelFilter, Log, Metadata, Record};
1111
use std::fs::{self, File, OpenOptions};
12-
use std::io::{self, BufWriter, Write};
12+
use std::io::{self, Write};
1313
use std::path::{Path, PathBuf};
1414
use std::sync::{Arc, Mutex};
1515

@@ -29,7 +29,7 @@ pub struct ServerLogger {
2929
/// The maximum log level to display
3030
level: LevelFilter,
3131
/// The file to write logs to, protected by a mutex for thread-safe access
32-
file: Mutex<BufWriter<File>>,
32+
file: Mutex<File>,
3333
/// Path to the log file for reopening on SIGHUP
3434
log_file_path: PathBuf,
3535
}
@@ -155,9 +155,8 @@ fn format_level(level: Level) -> &'static str {
155155
}
156156
}
157157

158-
fn open_log_file(log_file_path: &Path) -> Result<BufWriter<File>, io::Error> {
159-
let file = OpenOptions::new().create(true).append(true).open(log_file_path)?;
160-
Ok(BufWriter::new(file))
158+
fn open_log_file(log_file_path: &Path) -> Result<File, io::Error> {
159+
OpenOptions::new().create(true).append(true).open(log_file_path)
161160
}
162161

163162
/// Wrapper to allow Arc<ServerLogger> to implement Log trait

0 commit comments

Comments
 (0)