#![cfg_attr(
any(feature = "systemd", feature = "wasm32"),
doc = r"
# Initialization
Call [`init`] from `main` for the zero-config path, or [`init_with`] with an
[`InitOptions`] builder for explicit format / sink / filter / OTLP
configuration. See the crate README for worked examples. On
`wasm32-unknown-unknown`, enable only the `wasm32` feature to install a panic
hook and emit `tracing` events to the JavaScript console. This path is suitable
for Cloudflare Workers via `workers-rs`; systemd, Actix Web, and OTLP exporter
features are native-only."
)]
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#[cfg(all(feature = "systemd", feature = "wasm32"))]
compile_error!("Feature \"systemd\" can't be combined with \"wasm32\".");
#[cfg(all(feature = "with-actix-web", feature = "wasm32"))]
compile_error!("Feature \"with-actix-web\" can't be combined with \"wasm32\".");
#[cfg(all(feature = "with-otlp", feature = "wasm32"))]
compile_error!("Feature \"with-otlp\" can't be combined with \"wasm32\".");
#[cfg(all(feature = "with-otlp", not(feature = "systemd")))]
compile_error!("Feature \"with-otlp\" requires \"systemd\".");
#[cfg(not(feature = "correlation"))]
compile_error!(
"At least feature \"correlation\", \"systemd\", \"wasm32\", or \"with-actix-web\" must be enabled."
);
#[cfg(feature = "correlation")]
pub mod correlation;
#[cfg(any(feature = "systemd", feature = "wasm32"))]
mod init;
#[cfg(any(feature = "systemd", feature = "wasm32"))]
mod options;
#[cfg(feature = "with-actix-web")]
mod actix;
#[cfg(feature = "with-otlp")]
pub mod otlp;
#[cfg(any(feature = "systemd", feature = "wasm32"))]
pub use crate::init::{init, init_or_skip, init_with};
#[cfg(any(feature = "systemd", feature = "wasm32"))]
pub use crate::options::{Format, InitOptions, ParseFormatError, ParseSinkError, Sink};
#[cfg(feature = "with-actix-web")]
pub use crate::actix::{EnrichedRootSpanBuilder, get_actix_web_logger, get_actix_web_logger_with};
#[cfg(feature = "with-otlp")]
pub use crate::otlp::{SpanProcessorMode, flush_otlp, shutdown_otlp};
pub use tracing::{Level, Span, debug, enabled, error, event, info, instrument, span, trace, warn};
#[cfg(any(feature = "systemd", feature = "wasm32"))]
#[non_exhaustive]
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("{0}")]
IO(#[from] std::io::Error),
#[error("logging subscriber already initialized")]
AlreadyInitialized,
#[error("invalid logging configuration: {0}")]
InvalidConfiguration(String),
#[error("invalid {variable}: expected {expected}")]
InvalidEnvironmentValue {
variable: String,
expected: &'static str,
},
#[error("a foreign tracing subscriber already owns the process-global slot")]
ForeignGlobalSubscriber,
#[cfg(feature = "systemd")]
#[error("a foreign logger already owns the process-global log facade")]
ForeignGlobalLogger,
#[cfg(feature = "systemd")]
#[error("logging installation stopped before the log bridge committed")]
InstallationIncomplete,
#[cfg(feature = "with-otlp")]
#[error("OTLP init failed: {0}")]
OtlpInit(String),
}