Skip to content

Commit aa9ed88

Browse files
authored
fix: target_static should return static str (#198)
Signed-off-by: tison <[email protected]>
1 parent b0b989b commit aa9ed88

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased
66

7+
## [0.29.1] 2025-11-03
8+
9+
### Bug fixes
10+
11+
* `Record::target_static` should return `&'static str` instead of `&str`.
12+
713
## [0.29.0] 2025-11-03
814

915
### Breaking changes

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ logforth-append-async = { version = "0.3.0", path = "appenders/async" }
3838
logforth-append-fastrace = { version = "0.3.0", path = "appenders/fastrace" }
3939
logforth-append-file = { version = "0.3.0", path = "appenders/file" }
4040
logforth-append-journald = { version = "0.3.0", path = "appenders/journald" }
41-
logforth-append-opentelemetry = { version = "0.3.0", path = "appenders/opentelemetry" }
41+
logforth-append-opentelemetry = { version = "0.3.1", path = "appenders/opentelemetry" }
4242
logforth-append-syslog = { version = "0.3.0", path = "appenders/syslog" }
4343
logforth-bridge-log = { version = "0.3.0", path = "bridges/log" }
44-
logforth-core = { version = "0.3.0", path = "core" }
44+
logforth-core = { version = "0.3.1", path = "core" }
4545
logforth-diagnostic-fastrace = { version = "0.3.0", path = "diagnostics/fastrace" }
4646
logforth-diagnostic-task-local = { version = "0.3.0", path = "diagnostics/task-local" }
4747
logforth-layout-google-cloud-logging = { version = "0.3.0", path = "layouts/google-cloud-logging" }

appenders/opentelemetry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[package]
1616
name = "logforth-append-opentelemetry"
17-
version = "0.3.0"
17+
version = "0.3.1"
1818

1919
description = "Opemtelemetry appender for Logforth."
2020
keywords = ["logging", "log", "opentelemtry"]

appenders/opentelemetry/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,12 @@ impl Append for OpentelemetryLog {
232232
log_record.set_observed_timestamp(now);
233233
log_record.set_severity_number(log_level_to_otel_severity(record.level()));
234234
log_record.set_severity_text(record.level().name());
235-
log_record.set_target(record.target().to_owned());
235+
236+
if let Some(target) = record.target_static() {
237+
log_record.set_target(target);
238+
} else {
239+
log_record.set_target(record.target().to_owned());
240+
}
236241

237242
if let Some(make_body) = self.make_body.as_ref() {
238243
log_record.set_body(make_body.create(record, diags)?);
@@ -258,6 +263,10 @@ impl Append for OpentelemetryLog {
258263
log_record.add_attribute("line", line);
259264
}
260265

266+
if let Some(column) = record.column() {
267+
log_record.add_attribute("column", column);
268+
}
269+
261270
let mut extractor = KvExtractor {
262271
record: &mut log_record,
263272
};

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[package]
1616
name = "logforth-core"
17-
version = "0.3.0"
17+
version = "0.3.1"
1818

1919
description = "Core structs and functions for Logforth."
2020
keywords = ["logging", "log"]

core/src/record.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'a> Record<'a> {
6969
/// The name of the target of the directive, if it is a `'static` str.
7070
///
7171
/// This is typically the same as the module path, but can be set explicitly.
72-
pub fn target_static(&self) -> Option<&'a str> {
72+
pub fn target_static(&self) -> Option<&'static str> {
7373
self.target.get_static()
7474
}
7575

logforth/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[package]
1616
name = "logforth"
17-
version = "0.29.0"
17+
version = "0.29.1"
1818

1919
description = "A versatile and extensible logging implementation."
2020
keywords = ["logging", "log", "opentelemetry", "fastrace"]

0 commit comments

Comments
 (0)