Skip to content

Commit

Permalink
new: added support for numeric caller-line
Browse files Browse the repository at this point in the history
  • Loading branch information
pamburus committed Dec 13, 2023
1 parent 4cb48b3 commit ad17009
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ categories = ["command-line-utilities"]
description = "Utility for viewing json-formatted log files."
keywords = ["cli", "human", "log"]
name = "hl"
version = "0.22.0"
version = "0.22.1"
edition = "2021"
build = "build.rs"

Expand Down
6 changes: 4 additions & 2 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ impl RecordFormatter {
}
Caller::FileLine(file, line) => {
buf.extend_from_slice(file.as_bytes());
buf.push(b':');
buf.extend_from_slice(line.as_bytes());
if line.len() != 0 {
buf.push(b':');
buf.extend_from_slice(line.as_bytes());
}
}
};
});
Expand Down
4 changes: 3 additions & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ impl FieldSettings {
to.caller = Some(Caller::FileLine("", value.get()));
}
Some(Caller::FileLine(_, line)) => {
if let Some(value) = json::from_str(value.get()).ok() {
if value.get().bytes().next().map_or(false, |x| x.is_ascii_digit()) {
*line = value.get()
} else if let Some(value) = json::from_str(value.get()).ok() {
*line = value
}
}
Expand Down

0 comments on commit ad17009

Please sign in to comment.