async fn init(filename: impl ToString) -> io::Result<thread::JoinHandle<()>> {
        let (log_tx, log_rx) = channel(1);
        let (wait_tx, wait_rx) =  std::sync::mpsc::sync_channel(0);

        let mut guard = LOGGER.lock().unwrap();
        *guard = Some(LogSender{
            tx:         log_tx.clone(),
            wait:       wait_rx,
        });

        let mut d = LogWriter {
            file:   None,
            name:   filename.to_string(),
            dev:    0,
            ino:    0,
            recv:   log_rx,
            wait:   wait_tx,
        };
        d.reopen(false)?;

        // Every second, send a LogItem::Tick.
        task::spawn(async move {
            loop {
                time::sleep(Duration::from_millis(1000)).await;
                if let Err(_) = log_tx.send(LogItem::Tick).await {
                    break;
                }
            }
        });

        // Spawn a thread for the sync DataLog::run method.
        Ok(thread::spawn(move || {
            d.run();
        }))
    }
// Initialize logwriter. If the datalog file cannot be
// opened, return an error. Otherwise spawn a background
// thread to process log messages and return the thread handle.
Initialize logwriter. If the datalog file cannot be
opened, return an error. Otherwise spawn a background
thread to process log messages and return the thread handle.
Initialize logwriter . If the datalog file cannot be opened return an error . Otherwise spawn a background thread to process log messages and return the thread handle .
async fn init(filename: impl ToString) -> io::Result<thread::JoinHandle<()>> {
        let (log_tx, log_rx) = channel(1);
        let (wait_tx, wait_rx) =  std::sync::mpsc::sync_channel(0);
        let mut guard = LOGGER.lock().unwrap();
        *guard = Some(LogSender{
            tx:         log_tx.clone(),
            wait:       wait_rx,
        });
        let mut d = LogWriter {
            file:   None,
            name:   filename.to_string(),
            dev:    0,
            ino:    0,
            recv:   log_rx,
            wait:   wait_tx,
        };
        d.reopen(false)?;
        // Every second, send a LogItem::Tick.
        task::spawn(async move {
            loop {
                time::sleep(Duration::from_millis(1000)).await;
                if let Err(_) = log_tx.send(LogItem::Tick).await {
                    break;
                }
            }
        });
        // Spawn a thread for the sync DataLog::run method.
        Ok(thread::spawn(move || {
            d.run();
        }))
    }
async fn init ( filename : impl ToString ) -> io :: Result < thread :: JoinHandle < ( ) > > { let ( log_tx , log_rx ) = channel ( 1 ) ; let ( wait_tx , wait_rx ) = std :: sync :: mpsc :: sync_channel ( 0 ) ; let mut guard = LOGGER . lock ( ) . unwrap ( ) ; * guard = Some ( LogSender { tx : log_tx . clone ( ) , wait : wait_rx , } ) ; let mut d = LogWriter { file : None , name : filename . to_string ( ) , dev : 0 , ino : 0 , recv : log_rx , wait : wait_tx , } ; d . reopen ( false ) ? ; // Every second, send a LogItem::Tick. task :: spawn ( async move { loop { time :: sleep ( Duration :: from_millis ( 1000 ) ) . await ; if let Err ( _ ) = log_tx . send ( LogItem :: Tick ) . await { break ; } } } ) ; // Spawn a thread for the sync DataLog::run method. Ok ( thread :: spawn ( move | | { d . run ( ) ; } ) ) }
Initialize logwriter.
Initialize logwriter .
filename
impl ToString