Trait LoggerPlugin

Source
pub trait LoggerPlugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> String;
    fn log_string(&self, message: &str) -> Result<(), String>;

    // Provided methods
    fn log_status(&self, status: &LogStatus) -> Result<(), String> { ... }
    fn log_snapshot(&self, snapshot: &str) -> Result<(), String> { ... }
    fn init(&self, _name: &str) -> Result<(), String> { ... }
    fn health(&self) -> Result<(), String> { ... }
    fn shutdown(&self) { ... }
}
Expand description

Trait that logger plugins must implement.

§Example

use osquery_rust_ng::plugin::{LoggerPlugin, LogStatus, LogSeverity};

struct MyLogger;

impl LoggerPlugin for MyLogger {
    fn name(&self) -> String {
        "my_logger".to_string()
    }

    fn log_string(&self, message: &str) -> Result<(), String> {
        println!("Log: {}", message);
        Ok(())
    }
}

Required Methods§

Source

fn name(&self) -> String

Returns the name of the logger plugin

Source

fn log_string(&self, message: &str) -> Result<(), String>

Log a raw string message.

This is called for general log entries and query results.

Provided Methods§

Source

fn log_status(&self, status: &LogStatus) -> Result<(), String>

Log structured status information.

Called when osquery sends status logs with severity, file, line, and message.

Source

fn log_snapshot(&self, snapshot: &str) -> Result<(), String>

Log a snapshot (periodic state dump).

Snapshots are periodic dumps of osquery’s internal state.

Source

fn init(&self, _name: &str) -> Result<(), String>

Initialize the logger.

Called when the logger is first registered with osquery.

Source

fn health(&self) -> Result<(), String>

Health check for the logger.

Called periodically to ensure the logger is still functioning.

Source

fn shutdown(&self)

Shutdown the logger.

Called when osquery is shutting down.

Implementors§