tiny_tracing/errors.rs
1use thiserror::Error;
2
3/// Errors that can occur when configuring and initialising the logger.
4#[derive(Error, Debug, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum LoggerError {
7 /// The supplied format string is not a known [`LogFormat`](crate::LogFormat).
8 ///
9 /// Returned by `LogFormat::from_str`, not by `Logger::init` — the builder
10 /// itself is typed, so this cannot occur when values are passed as enums.
11 #[error("Invalid log format: '{0}'. Valid formats are: 'text', 'json'.")]
12 InvalidFormat(String),
13 /// The env filter string could not be parsed by
14 /// [`EnvFilter`](tracing_subscriber::EnvFilter).
15 #[error("Invalid env filter: '{0}'.")]
16 InvalidEnvFilter(String),
17 /// The log file could not be opened for writing.
18 #[error("Could not open log file '{path}': {message}")]
19 OpenLogFile {
20 /// Path that failed to open.
21 path: String,
22 /// Underlying I/O error message.
23 message: String,
24 },
25 /// A global tracing subscriber is already set (double-init).
26 #[error("Failed to initialize subscriber: {0}")]
27 TryInitError(String),
28}