pub struct LogsCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker logs command builder
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl LogsCommand
impl LogsCommand
Sourcepub fn timestamps(self) -> Self
pub fn timestamps(self) -> Self
Show timestamps
Sourcepub fn tail(self, lines: impl Into<String>) -> Self
pub fn tail(self, lines: impl Into<String>) -> Self
Number of lines to show from the end of the logs
Sourcepub fn since(self, timestamp: impl Into<String>) -> Self
pub fn since(self, timestamp: impl Into<String>) -> Self
Show logs since timestamp (e.g., 2013-01-02T13:23:37Z) or relative (e.g., 42m)
Sourcepub async fn run(&self) -> Result<CommandOutput>
pub async fn run(&self) -> Result<CommandOutput>
Execute the logs command
§Errors
Returns an error if:
- The Docker daemon is not running
- The specified container doesn’t exist
- The container has been removed
Source§impl LogsCommand
impl LogsCommand
Sourcepub async fn stream<F>(&self, handler: F) -> Result<StreamResult>
pub async fn stream<F>(&self, handler: F) -> Result<StreamResult>
Stream container logs with a custom handler
This is particularly useful with the follow
option to stream logs in real-time.
§Examples
use docker_wrapper::LogsCommand;
use docker_wrapper::StreamHandler;
// Follow logs in real-time
let result = LogsCommand::new("mycontainer")
.follow()
.timestamps()
.stream(StreamHandler::print())
.await?;
§Errors
Returns an error if the command fails or encounters an I/O error
Trait Implementations§
Source§impl Clone for LogsCommand
impl Clone for LogsCommand
Source§fn clone(&self) -> LogsCommand
fn clone(&self) -> LogsCommand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for LogsCommand
impl Debug for LogsCommand
Source§impl DockerCommand for LogsCommand
impl DockerCommand for LogsCommand
Source§type Output = CommandOutput
type Output = CommandOutput
The output type this command produces
Source§fn get_executor(&self) -> &CommandExecutor
fn get_executor(&self) -> &CommandExecutor
Get the command executor for extensibility
Source§fn get_executor_mut(&mut self) -> &mut CommandExecutor
fn get_executor_mut(&mut self) -> &mut CommandExecutor
Get mutable command executor for extensibility
Source§fn build_command_args(&self) -> Vec<String>
fn build_command_args(&self) -> Vec<String>
Build the complete command arguments including subcommands
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the command and return the typed output
Source§fn execute_command<'life0, 'async_trait>(
&'life0 self,
command_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn execute_command<'life0, 'async_trait>(
&'life0 self,
command_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Helper method to execute the command with proper error handling
Source§fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
Add a raw argument to the command (escape hatch)
Source§impl StreamableCommand for LogsCommand
impl StreamableCommand for LogsCommand
Source§fn stream<'life0, 'async_trait, F>(
&'life0 self,
handler: F,
) -> Pin<Box<dyn Future<Output = Result<StreamResult>> + Send + 'async_trait>>where
F: FnMut(OutputLine) + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait, F>(
&'life0 self,
handler: F,
) -> Pin<Box<dyn Future<Output = Result<StreamResult>> + Send + 'async_trait>>where
F: FnMut(OutputLine) + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Run the command with streaming output Read more
Source§fn stream_channel<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(Receiver<OutputLine>, StreamResult)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream_channel<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(Receiver<OutputLine>, StreamResult)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the command with streaming output via a channel Read more
Auto Trait Implementations§
impl Freeze for LogsCommand
impl RefUnwindSafe for LogsCommand
impl Send for LogsCommand
impl Sync for LogsCommand
impl Unpin for LogsCommand
impl UnwindSafe for LogsCommand
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