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 features(&self) -> i32 { ... }
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§
Provided Methods§
Sourcefn log_status(&self, status: &LogStatus) -> Result<(), String>
fn log_status(&self, status: &LogStatus) -> Result<(), String>
Log structured status information.
Called when osquery sends status logs with severity, file, line, and message.
Sourcefn log_snapshot(&self, snapshot: &str) -> Result<(), String>
fn log_snapshot(&self, snapshot: &str) -> Result<(), String>
Log a snapshot (periodic state dump).
Snapshots are periodic dumps of osquery’s internal state.
Sourcefn init(&self, _name: &str) -> Result<(), String>
fn init(&self, _name: &str) -> Result<(), String>
Initialize the logger.
Called when the logger is first registered with osquery.
Sourcefn health(&self) -> Result<(), String>
fn health(&self) -> Result<(), String>
Health check for the logger.
Called periodically to ensure the logger is still functioning.
Sourcefn features(&self) -> i32
fn features(&self) -> i32
Returns the features this logger supports.
Override this method to advertise additional capabilities to osquery. By default, loggers advertise support for status logs.
§Example
use osquery_rust_ng::plugin::{LoggerPlugin, LoggerFeatures};
struct MyLogger;
impl LoggerPlugin for MyLogger {
fn name(&self) -> String { "my_logger".to_string() }
fn log_string(&self, _: &str) -> Result<(), String> { Ok(()) }
fn features(&self) -> i32 {
// Support both status logs and event forwarding
LoggerFeatures::LOG_STATUS | LoggerFeatures::LOG_EVENT
}
}