From 6df2f419fbffd2903491dbcdbf9306779d709ad3 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Sun, 26 Oct 2025 08:01:17 -0700 Subject: [PATCH 1/4] Add docs for target-specific formatters in log plugin --- src/content/docs/plugin/logging.mdx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/content/docs/plugin/logging.mdx b/src/content/docs/plugin/logging.mdx index 5a5faaa581..46eba4afeb 100644 --- a/src/content/docs/plugin/logging.mdx +++ b/src/content/docs/plugin/logging.mdx @@ -342,6 +342,32 @@ tauri_plugin_log::Builder::new() .build() ``` +### Applying a different format to targets + +You can specify your own log format for specific targets by using the `format` method +on `tauri_plugin_log::Target`. You may also wish to call `clear_format` on the builder +to remove the default formatter, which is applied to all targets: + +```rust +tauri_plugin_log::Builder::new() + .clear_format() + .targets([ + tauri_plugin_log::Target::new( + tauri_plugin_log::TargetKind::Stdout + ) + .format(move |out, message, record| { + // custom formatter for stdout + }), + tauri_plugin_log::Target::new( + tauri_plugin_log::TargetKind::LogDir { file_name: None } + ) + .format(move |out, message, record| { + // custom formatter for log files + }), + ]) + .build(), +``` + #### Log dates By default the log plugin uses the UTC timezone to format dates From f8078502ff2f313d8f9c2728a2993ffc5f61cf31 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Mon, 27 Oct 2025 09:59:14 -0700 Subject: [PATCH 2/4] Change clear_format to reset_format --- src/content/docs/plugin/logging.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/plugin/logging.mdx b/src/content/docs/plugin/logging.mdx index 46eba4afeb..d6ea9cf993 100644 --- a/src/content/docs/plugin/logging.mdx +++ b/src/content/docs/plugin/logging.mdx @@ -345,12 +345,12 @@ tauri_plugin_log::Builder::new() ### Applying a different format to targets You can specify your own log format for specific targets by using the `format` method -on `tauri_plugin_log::Target`. You may also wish to call `clear_format` on the builder +on `tauri_plugin_log::Target`. You may also wish to call `reset_format` on the builder to remove the default formatter, which is applied to all targets: ```rust tauri_plugin_log::Builder::new() - .clear_format() + .reset_format() .targets([ tauri_plugin_log::Target::new( tauri_plugin_log::TargetKind::Stdout From 849f0434030998e5412b7b8b53d044b54b9718e3 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Tue, 4 Nov 2025 08:01:30 -0800 Subject: [PATCH 3/4] reset_format -> clear_format --- src/content/docs/plugin/logging.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/plugin/logging.mdx b/src/content/docs/plugin/logging.mdx index d6ea9cf993..984fe95498 100644 --- a/src/content/docs/plugin/logging.mdx +++ b/src/content/docs/plugin/logging.mdx @@ -350,7 +350,7 @@ to remove the default formatter, which is applied to all targets: ```rust tauri_plugin_log::Builder::new() - .reset_format() + .clear_format() .targets([ tauri_plugin_log::Target::new( tauri_plugin_log::TargetKind::Stdout From 4e937e0c2e2172aff718b51f0071dca29ff1915f Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Tue, 4 Nov 2025 08:34:18 -0800 Subject: [PATCH 4/4] reset_format -> clear_format take 2 --- src/content/docs/plugin/logging.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/plugin/logging.mdx b/src/content/docs/plugin/logging.mdx index 984fe95498..46eba4afeb 100644 --- a/src/content/docs/plugin/logging.mdx +++ b/src/content/docs/plugin/logging.mdx @@ -345,7 +345,7 @@ tauri_plugin_log::Builder::new() ### Applying a different format to targets You can specify your own log format for specific targets by using the `format` method -on `tauri_plugin_log::Target`. You may also wish to call `reset_format` on the builder +on `tauri_plugin_log::Target`. You may also wish to call `clear_format` on the builder to remove the default formatter, which is applied to all targets: ```rust