Skip to content

Commit 2a49057

Browse files
author
Junfeng Li
committed
Truncate server log files only once in one session.
1 parent 2d53c68 commit 2a49057

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/languageclient.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,7 @@ impl ILanguageClient for Arc<Mutex<State>> {
848848

849849
let stderr = std::fs::OpenOptions::new()
850850
.create(true)
851-
.write(true)
852-
.truncate(true)
851+
.append(true)
853852
.open(&get_logpath_server())?;
854853

855854
let process = std::process::Command::new(command.get(0).ok_or_else(|| err_msg("Empty command!"))?)

src/logger.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ fn config(level: LogLevelFilter) -> Result<Config> {
1616

1717
pub fn init() -> Result<Handle> {
1818
{
19+
// Truncate log files.
1920
let mut f = std::fs::OpenOptions::new()
2021
.create(true)
2122
.write(true)
2223
.truncate(true)
2324
.open(utils::get_logpath())?;
2425
writeln!(f, "")?;
26+
let mut f = std::fs::OpenOptions::new()
27+
.create(true)
28+
.write(true)
29+
.truncate(true)
30+
.open(utils::get_logpath_server())?;
31+
writeln!(f, "")?;
2532
}
2633

2734
let handle = log4rs::init_config(config(LogLevelFilter::Warn)?)?;

0 commit comments

Comments
 (0)