mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 13:16:28 +00:00
improve code for audit
This commit is contained in:
Generated
+18
@@ -3523,6 +3523,18 @@ dependencies = [
|
|||||||
"x11",
|
"x11",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libz-sys"
|
||||||
|
version = "1.1.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
"vcpkg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.15"
|
version = "0.4.15"
|
||||||
@@ -7085,6 +7097,12 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vcpkg"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version-compare"
|
name = "version-compare"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ impl AuditTarget for FileAuditTarget {
|
|||||||
/// Send an audit entry to a file
|
/// Send an audit entry to a file
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `entry` - The audit entry to send
|
/// * `entry` - The audit entry to send
|
||||||
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use rustfs_logging::{AuditEntry, AuditTarget, FileAuditTarget};
|
/// use rustfs_logging::{AuditEntry, AuditTarget, FileAuditTarget};
|
||||||
@@ -75,7 +76,6 @@ impl AuditTarget for FileAuditTarget {
|
|||||||
/// };
|
/// };
|
||||||
/// FileAuditTarget.send(entry);
|
/// FileAuditTarget.send(entry);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
fn send(&self, entry: AuditEntry) {
|
fn send(&self, entry: AuditEntry) {
|
||||||
println!("File audit: {:?}", entry);
|
println!("File audit: {:?}", entry);
|
||||||
}
|
}
|
||||||
@@ -83,6 +83,14 @@ impl AuditTarget for FileAuditTarget {
|
|||||||
|
|
||||||
#[cfg(feature = "audit-webhook")]
|
#[cfg(feature = "audit-webhook")]
|
||||||
/// Webhook audit objectives
|
/// Webhook audit objectives
|
||||||
|
/// #Arguments
|
||||||
|
/// * `client` - The reqwest client
|
||||||
|
/// * `url` - The URL of the webhook
|
||||||
|
/// # Example
|
||||||
|
/// ```
|
||||||
|
/// use rustfs_logging::WebhookAuditTarget;
|
||||||
|
/// let target = WebhookAuditTarget::new("http://localhost:8080");
|
||||||
|
/// ```
|
||||||
pub struct WebhookAuditTarget {
|
pub struct WebhookAuditTarget {
|
||||||
client: Client,
|
client: Client,
|
||||||
url: String,
|
url: String,
|
||||||
@@ -113,6 +121,52 @@ impl AuditTarget for WebhookAuditTarget {
|
|||||||
|
|
||||||
#[cfg(feature = "audit-kafka")]
|
#[cfg(feature = "audit-kafka")]
|
||||||
/// Kafka audit objectives
|
/// Kafka audit objectives
|
||||||
|
/// # Arguments
|
||||||
|
/// * `producer` - The Kafka producer
|
||||||
|
/// * `topic` - The Kafka topic
|
||||||
|
/// # Example
|
||||||
|
/// ```
|
||||||
|
/// use rustfs_logging::KafkaAuditTarget;
|
||||||
|
/// let target = KafkaAuditTarget::new("localhost:9092", "rustfs-audit");
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// This feature requires the `rdkafka` crate
|
||||||
|
/// # Example
|
||||||
|
/// ```toml
|
||||||
|
/// [dependencies]
|
||||||
|
/// rdkafka = "0.26.0"
|
||||||
|
/// rustfs_logging = { version = "0.1.0", features = ["audit-kafka"] }
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// The `rdkafka` crate requires the `librdkafka` library to be installed
|
||||||
|
/// # Example
|
||||||
|
/// ```sh
|
||||||
|
/// sudo apt-get install librdkafka-dev
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// The `rdkafka` crate requires the `libssl-dev` and `pkg-config` packages to be installed
|
||||||
|
/// # Example
|
||||||
|
/// ```sh
|
||||||
|
/// sudo apt-get install libssl-dev pkg-config
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// The `rdkafka` crate requires the `zlib1g-dev` package to be installed
|
||||||
|
/// # Example
|
||||||
|
/// ```sh
|
||||||
|
/// sudo apt-get install zlib1g-dev
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// The `rdkafka` crate requires the `zstd` package to be installed
|
||||||
|
/// # Example
|
||||||
|
/// ```sh
|
||||||
|
/// sudo apt-get install zstd
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// The `rdkafka` crate requires the `lz4` package to be installed
|
||||||
|
/// # Example
|
||||||
|
/// ```sh
|
||||||
|
/// sudo apt-get install lz4
|
||||||
|
/// ```
|
||||||
pub struct KafkaAuditTarget {
|
pub struct KafkaAuditTarget {
|
||||||
producer: FutureProducer,
|
producer: FutureProducer,
|
||||||
topic: String,
|
topic: String,
|
||||||
@@ -178,7 +232,31 @@ impl AuditTarget for KafkaAuditTarget {
|
|||||||
/// logger.log(entry).await;
|
/// logger.log(entry).await;
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
/// AuditLogger is a logger that logs audit entries
|
||||||
|
/// to multiple targets
|
||||||
|
/// # Example
|
||||||
|
/// ```
|
||||||
|
/// use rustfs_logging::{AuditEntry, AuditLogger, FileAuditTarget};
|
||||||
|
/// let logger = AuditLogger::new(vec![Box::new(FileAuditTarget)]);
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// This feature requires the `tokio` crate
|
||||||
|
/// # Example
|
||||||
|
/// ```toml
|
||||||
|
/// [dependencies]
|
||||||
|
/// tokio = { version = "1", features = ["full"] }
|
||||||
|
/// rustfs_logging = { version = "0.1.0"}
|
||||||
|
/// ```
|
||||||
|
/// # Note
|
||||||
|
/// This feature requires the `serde` crate
|
||||||
|
/// # Example
|
||||||
|
/// ```toml
|
||||||
|
/// [dependencies]
|
||||||
|
/// serde = { version = "1", features = ["derive"] }
|
||||||
|
/// rustfs_logging = { version = "0.1.0"}
|
||||||
|
/// ```
|
||||||
pub struct AuditLogger {
|
pub struct AuditLogger {
|
||||||
tx: mpsc::Sender<AuditEntry>,
|
tx: mpsc::Sender<AuditEntry>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user