Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display target instead of module_path #82

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## Unreleased

* `module_path` is replaced by `target` in `JsonLayout` and `TextLayout` ([#85](https://github.com/fast/logforth/pull/82)).

## [0.18.1] 2024-11-17

### New features
Expand Down
4 changes: 2 additions & 2 deletions src/layout/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(crate) struct RecordLine<'a> {
#[serde(serialize_with = "serialize_time_zone")]
timestamp: Zoned,
level: &'a str,
module_path: &'a str,
target: &'a str,
file: &'a str,
line: u32,
#[serde(serialize_with = "serialize_args")]
Expand Down Expand Up @@ -121,7 +121,7 @@ impl JsonLayout {
None => Zoned::now(),
},
level: record.level().as_str(),
module_path: record.module_path().unwrap_or_default(),
target: record.target(),
file: record.file().unwrap_or_default(),
line: record.line().unwrap_or_default(),
message: record.args(),
Expand Down
4 changes: 2 additions & 2 deletions src/layout/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ impl TextLayout {
};
ColoredString::from(record.level().to_string()).color(color)
};
let module = record.module_path().unwrap_or_default();
let target = record.target();
let file = filename(record);
let line = record.line().unwrap_or_default();
let message = record.args();
let kvs = KvDisplay::new(record.key_values());
Ok(format!("{time:.6} {level:>5} {module}: {file}:{line} {message}{kvs}").into_bytes())
Ok(format!("{time:.6} {level:>5} {target}: {file}:{line} {message}{kvs}").into_bytes())
}
}

Expand Down