You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a `is_skip_logger` flag to the Log Plugin `Builder` struct, a `skip_logger()` method to the Builder, and logic to avoid acquiring (creating) a logger and attaching it to the global logger. Since acquire_logger is pub, a `LoggerNotInitialized` is added and returned if it's called when the `is_skip_looger` flag is set. Overall, this feature permits a user to avoid calling `attach_logger` which can only be called once in a program's lifetime and allows the user to control the logger returned from `logger()`. Additionally, it also will allow users to generate multiple Tauri Mock apps in test suites that run and parallel and have the `log` plugin attached (assuming they use `skip_logger()`).
#[error("Internal logger disabled and cannot be acquired or attached")]
62
+
LoggerNotInitialized,
61
63
}
62
64
63
65
/// An enum representing the available verbosity levels of the logger.
@@ -230,6 +232,7 @@ pub struct Builder {
230
232
timezone_strategy:TimezoneStrategy,
231
233
max_file_size:u128,
232
234
targets:Vec<Target>,
235
+
is_skip_logger:bool,
233
236
}
234
237
235
238
implDefaultforBuilder{
@@ -258,6 +261,7 @@ impl Default for Builder {
258
261
timezone_strategy:DEFAULT_TIMEZONE_STRATEGY,
259
262
max_file_size:DEFAULT_MAX_FILE_SIZE,
260
263
targets:DEFAULT_LOG_TARGETS.into(),
264
+
is_skip_logger:false,
261
265
}
262
266
}
263
267
}
@@ -339,6 +343,22 @@ impl Builder {
339
343
self
340
344
}
341
345
346
+
/// Skip the creation and global registration of a logger
347
+
///
348
+
/// If you wish to use your own global logger, you must call `skip_logger` so that the plugin does not attempt to set a second global logger. In this configuration, no logger will be created and the plugin's `log` command will rely on the result of `log::logger()`. You will be responsible for configuring the logger yourself and any included targets will be ignored. This can also be used with `tracing-log` or if running tests in parallel that require the plugin to be registered.
0 commit comments