pub struct GoogleWriterRuntime<M: LogMapper> { /* private fields */ }
Expand description
Runtime that manages a background task for batching and sending logs to Google Cloud.
GoogleWriterRuntime
owns the background task, handles shutdown, and provides a
GoogleWriterHandle
for synchronous log writing. It is generic over a type implementing LogMapper
,
which is responsible for mapping structured log entries to the format expected by Google Cloud Logging.
Implementations§
Source§impl<M: LogMapper + Send + Sync + 'static> GoogleWriterRuntime<M>
impl<M: LogMapper + Send + Sync + 'static> GoogleWriterRuntime<M>
Sourcepub fn new(google_logger: GoogleLogger<M>, config: GoogleWriterConfig) -> Self
pub fn new(google_logger: GoogleLogger<M>, config: GoogleWriterConfig) -> Self
Creates a new GoogleWriterRuntime
and spawns the background batching task.
Logs are received via an unbounded channel, buffered, and flushed when:
- the buffer reaches
config.max_batch
entries, or config.max_delay
elapses since the last flush.
The background task also flushes any remaining logs on shutdown.
Sourcepub fn writer(&self) -> GoogleWriterHandle ⓘ
pub fn writer(&self) -> GoogleWriterHandle ⓘ
Returns a handle that implements std::io::Write
for sending log entries.
This handle can be cloned and shared across threads for synchronous logging.
Sourcepub async fn flush_and_wait(&self)
pub async fn flush_and_wait(&self)
Flushes all buffered logs and waits until the background task completes the flush.