mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
68 lines
1.9 KiB
Rust
68 lines
1.9 KiB
Rust
/// # obs
|
|
///
|
|
/// `obs` is a logging and observability library for Rust.
|
|
/// It provides a simple and easy-to-use interface for logging and observability.
|
|
/// It is built on top of the `log` crate and `opentelemetry` crate.
|
|
mod config;
|
|
mod entry;
|
|
mod logger;
|
|
mod sink;
|
|
mod telemetry;
|
|
mod utils;
|
|
mod worker;
|
|
|
|
pub use config::load_config;
|
|
pub use config::{AppConfig, OtelConfig};
|
|
pub use entry::audit::{ApiDetails, AuditEntry};
|
|
pub use entry::base::{Args, Entry, Info, LogKind, ObjectVersion, Trace, API};
|
|
pub use entry::log::{LogEntry, SerializableLevel};
|
|
pub use logger::start_logger;
|
|
pub use logger::{
|
|
ensure_logger_initialized, get_global_logger, init_global_logger, locked_logger, log_debug, log_error, log_info, log_trace,
|
|
log_warn, log_with_context,
|
|
};
|
|
pub use logger::{LogError, Logger};
|
|
pub use sink::Sink;
|
|
use std::sync::Arc;
|
|
pub use telemetry::init_telemetry;
|
|
use tokio::sync::Mutex;
|
|
pub use utils::{get_local_ip, get_local_ip_with_default};
|
|
pub use worker::start_worker;
|
|
|
|
/// Initialize the observability module
|
|
///
|
|
/// # Parameters
|
|
/// - `config`: Configuration information
|
|
///
|
|
/// # Returns
|
|
/// A tuple containing the logger and the telemetry guard
|
|
///
|
|
/// # Example
|
|
/// ```
|
|
/// use rustfs_obs::{AppConfig, init_obs};
|
|
///
|
|
/// let config = AppConfig::default();
|
|
/// let (logger, guard) = init_obs(config);
|
|
/// ```
|
|
pub async fn init_obs(config: AppConfig) -> (Arc<Mutex<Logger>>, telemetry::OtelGuard) {
|
|
let guard = init_telemetry(&config.observability);
|
|
let sinks = sink::create_sinks(&config);
|
|
let logger = init_global_logger(&config, sinks).await;
|
|
(logger, guard)
|
|
}
|
|
|
|
/// Get the global logger instance
|
|
/// This function returns a reference to the global logger instance.
|
|
///
|
|
/// # Returns
|
|
/// A reference to the global logger instance
|
|
///
|
|
/// # Example
|
|
/// ```
|
|
/// use rustfs_obs::get_logger;
|
|
/// let logger = get_logger();
|
|
/// ```
|
|
pub fn get_logger() -> &'static Arc<Mutex<Logger>> {
|
|
get_global_logger()
|
|
}
|