Crate quantum_log

Crate quantum_log 

Source
Expand description

QuantumLog - 高性能异步日志库

QuantumLog 是一个专为高性能计算环境设计的异步日志库, 支持多种输出格式和目标,包括文件、数据库和标准输出。

§快速开始

use quantum_log::{init, shutdown};
use tracing::{info, warn, error};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 初始化 QuantumLog
    init().await?;
     
    // 使用标准的 tracing 宏
    info!("Application started");
    warn!("This is a warning");
    error!("This is an error");
     
    // 优雅关闭
    shutdown().await?;
    Ok(())
}

§自定义配置

use quantum_log::{QuantumLogConfig, init_with_config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = QuantumLogConfig {
        global_level: "DEBUG".to_string(),
        ..Default::default()
    };
     
    quantum_log::init_with_config(config).await?;
     
    // 你的应用代码...
     
    quantum_log::shutdown().await?;
    Ok(())
}

Re-exports§

pub use config::load_config_from_file;
pub use config::BackpressureStrategy;
pub use config::OutputFormat;
pub use config::QuantumLogConfig;
pub use config::QuantumLoggerConfig;
pub use config::StdoutConfig;
pub use diagnostics::get_diagnostics;
pub use diagnostics::DiagnosticsSnapshot;
pub use error::QuantumLogError;
pub use error::Result;
pub use shutdown::ShutdownCoordinator;
pub use shutdown::ShutdownHandle as QuantumShutdownHandle;
pub use shutdown::ShutdownListener;
pub use shutdown::ShutdownSignal;
pub use shutdown::ShutdownState;
pub use core::event::QuantumLogEvent;
pub use core::subscriber::BufferStats;
pub use core::subscriber::QuantumLogSubscriber;
pub use core::subscriber::QuantumLogSubscriberBuilder;

Modules§

config
定义 QuantumLog (灵迹) 日志框架的所有配置结构体。
core
QuantumLog 核心模块
diagnostics
定义 QuantumLog (灵迹) 日志框架的内部诊断与指标。
env_config
环境变量配置模块
error
Error types for QuantumLog
mpi
MPI FFI 相关模块
shutdown
优雅停机模块
sinks
QuantumLog Sinks 模块
utils
实用工具模块

Structs§

ShutdownHandle
关闭句柄,用于优雅关闭日志系统

Constants§

VERSION
库版本

Statics§

IS_QUANTUM_LOG_INITIALIZED
QuantumLog 初始化标记 用于确保日志系统只被初始化一次

Functions§

get_buffer_stats
获取缓冲区统计信息
get_config
获取当前配置的引用
init
使用默认配置初始化 QuantumLog
init_quantum_logger
初始化 QuantumLog 日志系统
init_with_builder
使用构建器初始化 QuantumLog
init_with_config
使用指定配置初始化 QuantumLog
is_initialized
检查 QuantumLog 是否已初始化
shutdown
优雅关闭 QuantumLog