Skip to content

Commit

Permalink
Line numbers logging implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
fvacek committed Nov 11, 2023
1 parent 5965c06 commit e0abd42
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,12 @@ impl Log for SimpleLogger {
}
};

let target = if !record.target().is_empty() {
record.target()
let target = if record.target().is_empty() || record.target() == record.module_path().unwrap_or_default() {
"".to_string()
} else {
record.module_path().unwrap_or_default()
format!("({})", record.target())
};
let module = format!("{}:{}", record.module_path().unwrap_or_default(), record.line().unwrap_or_default());

let thread = {
#[cfg(feature = "threads")]
Expand Down Expand Up @@ -475,7 +476,7 @@ impl Log for SimpleLogger {
""
};

let message = format!("{}{} [{}{}] {}", timestamp, level_string, target, thread, record.args());
let message = format!("{}{} [{}{}]{} {}", timestamp, level_string, module, thread, target, record.args());

#[cfg(not(feature = "stderr"))]
println!("{}", message);
Expand Down

0 comments on commit e0abd42

Please sign in to comment.