From ad17009d5839a0bdc84a91923932add9426ed350 Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Wed, 13 Dec 2023 20:30:51 +0100 Subject: [PATCH] new: added support for numeric caller-line --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/formatting.rs | 6 ++++-- src/model.rs | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8efd130f..60594f42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -718,7 +718,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hl" -version = "0.22.0" +version = "0.22.1" dependencies = [ "atoi", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 447b7c5b..ab61d100 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/formatting.rs b/src/formatting.rs index a7d4e472..29344a6b 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -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()); + } } }; }); diff --git a/src/model.rs b/src/model.rs index f389d501..f6568492 100644 --- a/src/model.rs +++ b/src/model.rs @@ -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 } }