Skip to content

Commit

Permalink
log: append rather than truncate
Browse files Browse the repository at this point in the history
When passing `-Clink-arg=--log-file=path-to-file` to rustc through
cargo, it's likely that the linker is going to be used multiple times
concurrently.  This isn't ideal because the logs interleave; it would be
better to change the flag semantics to --log-dir so that each linker
instance can have its own log file, but that is left for another day.
  • Loading branch information
tamird committed Jul 19, 2023
1 parent 8192b41 commit 9c5842e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bin/bpf-linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use simplelog::{
};
use std::{
env,
fs::{self, File},
fs::{self, OpenOptions},
path::PathBuf,
str::FromStr,
};
Expand Down Expand Up @@ -190,8 +190,8 @@ fn main() {
_ => None,
};
let log_level = log_level.or(env_log_level).unwrap_or(LevelFilter::Warn);
if let Some(path) = log_file {
let log_file = match File::create(path) {
if let Some(log_file) = log_file {
let log_file = match OpenOptions::new().create(true).append(true).open(log_file) {
Ok(f) => f,
Err(e) => {
error(
Expand Down

0 comments on commit 9c5842e

Please sign in to comment.