logup 0.1.0

Logup is a UNIX-style command that can be used to pipe stdout logs to location on disk or in the cloud without the need of an agent, logrotate, systemd or other configuration files
Documentation
use async_trait::async_trait;
use std::time::SystemTime;
use tokio::io::AsyncWriteExt;

#[cfg(test)]
use mockall::{automock, predicate::*};

#[cfg_attr(test, automock)]
#[async_trait]
pub trait AsyncLogWriter {
    async fn write_logs(&mut self, time: SystemTime, buf: &[u8]) -> std::io::Result<()>;
}

#[async_trait]
impl AsyncLogWriter for tokio::io::Stdout {
    async fn write_logs(&mut self, _time: SystemTime, buf: &[u8]) -> std::io::Result<()> {
        self.write_all(buf).await
    }
}

#[async_trait]
impl<T: AsyncLogWriter + Send + ?Sized> AsyncLogWriter for Box<T> {
    async fn write_logs(&mut self, time: SystemTime, buf: &[u8]) -> std::io::Result<()> {
        (**self).write_logs(time, buf).await
    }
}