pub struct CloudWatchLogger { /* private fields */ }Expand description
AWS CloudWatch Logs implementation of CloudLogger.
This implementation provides:
- Batched log export for efficiency
- Structured logging support
- Automatic log stream creation
- Log group configuration
§Example
use llm_shield_cloud_aws::CloudWatchLogger;
use llm_shield_cloud::{CloudLogger, LogLevel};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let logger = CloudWatchLogger::new(
"/llm-shield/api",
"production-instance-1"
).await?;
logger.log("Application started", LogLevel::Info).await?;
Ok(())
}Implementations§
Source§impl CloudWatchLogger
impl CloudWatchLogger
Sourcepub async fn new(
log_group: impl Into<String>,
log_stream: impl Into<String>,
) -> Result<Self>
pub async fn new( log_group: impl Into<String>, log_stream: impl Into<String>, ) -> Result<Self>
Sourcepub async fn new_with_config(
log_group: impl Into<String>,
log_stream: impl Into<String>,
region: impl Into<String>,
batch_size: usize,
) -> Result<Self>
pub async fn new_with_config( log_group: impl Into<String>, log_stream: impl Into<String>, region: impl Into<String>, batch_size: usize, ) -> Result<Self>
Sourcepub fn log_stream(&self) -> &str
pub fn log_stream(&self) -> &str
Gets the log stream this client is configured for.
Trait Implementations§
Source§impl CloudLogger for CloudWatchLogger
impl CloudLogger for CloudWatchLogger
Source§fn log<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 str,
level: LogLevel,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn log<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 str,
level: LogLevel,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes a simple log message. Read more
Auto Trait Implementations§
impl Freeze for CloudWatchLogger
impl !RefUnwindSafe for CloudWatchLogger
impl Send for CloudWatchLogger
impl Sync for CloudWatchLogger
impl Unpin for CloudWatchLogger
impl !UnwindSafe for CloudWatchLogger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.