pub enum Target {
Stdout,
Stderr,
Webview,
LogDir {
file_name: Option<String>,
},
Folder {
path: PathBuf,
file_name: Option<String>,
},
}Expand description
Specifies a log output destination.
Use these variants to configure where logs should be written. Multiple
targets can be combined using Builder::target() or Builder::targets().
§Example
use tauri_plugin_tracing::{Builder, Target};
// Log to stdout and webview (default behavior)
Builder::new()
.targets([Target::Stdout, Target::Webview])
.build::<tauri::Wry>();
// Log to file and webview only (no console)
Builder::new()
.targets([
Target::LogDir { file_name: None },
Target::Webview,
])
.build::<tauri::Wry>();
// Log to stderr instead of stdout
Builder::new()
.clear_targets()
.target(Target::Stderr)
.target(Target::Webview)
.build::<tauri::Wry>();Variants§
Stdout
Print logs to stdout.
Stderr
Print logs to stderr.
Webview
Forward logs to the webview via the tracing://log event.
This allows JavaScript code to receive logs using attachLogger()
or attachConsole().
LogDir
Write logs to the platform-standard log directory.
Platform log directories:
- macOS:
~/Library/Logs/{bundle_identifier} - Linux:
~/.local/share/{bundle_identifier}/logs - Windows:
%LOCALAPPDATA%/{bundle_identifier}/logs
The file_name parameter sets the log file prefix. Defaults to "app"
if None, producing files like app.2024-01-15.log.
Folder
Write logs to a custom directory.
The file_name parameter sets the log file prefix. Defaults to "app"
if None, producing files like app.2024-01-15.log.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Target
impl RefUnwindSafe for Target
impl Send for Target
impl Sync for Target
impl Unpin for Target
impl UnwindSafe for Target
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more