Skip to main content

logger

Function logger 

Source
pub fn logger() -> Dispatch
Expand description

Returns a fern::Dispatch already chained into the server’s log system, disabling the SDK’s default routing.

Lets the plugin customize format, level, sink (file, console) without giving up delivery to the server (SA-MP logprintf or ICore::logLnU8). The log crate level is mapped automatically to samp_sdk::omp::LogLevel in Open Multiplayer mode.

§Example

initialize_plugin!({
    let _ = fern::Dispatch::new()
        .format(|cb, msg, rec| cb.finish(format_args!("[MyPlugin][{}]: {}", rec.level(), msg)))
        .level(log::LevelFilter::Info)
        .chain(samp::plugin::logger())
        .apply();
    MyPlugin
});