Skip to content

Commit 1199f7d

Browse files
committed
Set log target to module path
The `log!()` macro defaults to using the module path as the log target when no target is specified. Explicitly setting the log target to the module path enables better integration with other logging crates, such as `env_logger`, allowing them to filter logs by target (e.g., via `env_logger::Builder::parse_filters()`).
1 parent 01c396a commit 1199f7d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/logger.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl LogWriter for Writer {
153153
#[cfg(not(feature = "uniffi"))]
154154
log::logger().log(
155155
&builder
156+
.target(record.module_path)
156157
.module_path(Some(record.module_path))
157158
.line(Some(record.line))
158159
.args(format_args!("{}", record.args))
@@ -161,6 +162,7 @@ impl LogWriter for Writer {
161162
#[cfg(feature = "uniffi")]
162163
log::logger().log(
163164
&builder
165+
.target(&record.module_path)
164166
.module_path(Some(&record.module_path))
165167
.line(Some(record.line))
166168
.args(format_args!("{}", record.args))

0 commit comments

Comments
 (0)