pub struct Logger { /* private fields */ }
Expand description
Server log processor
Implementations§
Source§impl Logger
impl Logger
Sourcepub fn new(config: &AppConfig) -> (Self, Receiver<UnifiedLogEntry>)
pub fn new(config: &AppConfig) -> (Self, Receiver<UnifiedLogEntry>)
Create a new Logger instance Returns Logger and corresponding Receiver
Sourcepub fn get_queue_capacity(&self) -> usize
pub fn get_queue_capacity(&self) -> usize
Sourcepub async fn log_server_entry(
&self,
entry: ServerLogEntry,
) -> Result<(), GlobalError>
pub async fn log_server_entry( &self, entry: ServerLogEntry, ) -> Result<(), GlobalError>
Log a server entry
Sourcepub async fn log_audit_entry(
&self,
entry: AuditLogEntry,
) -> Result<(), GlobalError>
pub async fn log_audit_entry( &self, entry: AuditLogEntry, ) -> Result<(), GlobalError>
Log an audit entry
Sourcepub async fn log_console_entry(
&self,
entry: ConsoleLogEntry,
) -> Result<(), GlobalError>
pub async fn log_console_entry( &self, entry: ConsoleLogEntry, ) -> Result<(), GlobalError>
Log a console entry
Sourcepub async fn log_entry(&self, entry: UnifiedLogEntry) -> Result<(), GlobalError>
pub async fn log_entry(&self, entry: UnifiedLogEntry) -> Result<(), GlobalError>
Asynchronous logging of unified log entries
Sourcepub async fn write_with_context(
&self,
message: &str,
source: &str,
level: Level,
request_id: Option<String>,
user_id: Option<String>,
fields: Vec<(String, String)>,
) -> Result<(), GlobalError>
pub async fn write_with_context( &self, message: &str, source: &str, level: Level, request_id: Option<String>, user_id: Option<String>, fields: Vec<(String, String)>, ) -> Result<(), GlobalError>
Write log with context information This function writes log messages with context information.
§Parameters
message
: Message to be loggedsource
: Source of the logrequest_id
: Request IDuser_id
: User IDfields
: Additional fields
§Returns
Result indicating whether the operation was successful
§Example
use tracing_core::Level;
use rustfs_obs::Logger;
async fn example(logger: &Logger) {
let _ = logger.write_with_context("This is an information message", "example",Level::INFO, Some("req-12345".to_string()), Some("user-6789".to_string()), vec![("endpoint".to_string(), "/api/v1/data".to_string())]).await;
}
Sourcepub async fn write(
&self,
message: &str,
source: &str,
level: Level,
) -> Result<(), GlobalError>
pub async fn write( &self, message: &str, source: &str, level: Level, ) -> Result<(), GlobalError>
Write log This function writes log messages.
§Parameters
message
: Message to be loggedsource
: Source of the loglevel
: Log level
§Returns
Result indicating whether the operation was successful
§Example
use rustfs_obs::Logger;
use tracing_core::Level;
async fn example(logger: &Logger) {
let _ = logger.write("This is an information message", "example", Level::INFO).await;
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Logger
impl RefUnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnwindSafe for Logger
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request