

use std::{sync::LazyLock, thread};
use std::time::Duration;



use syslog_rs::formatters::DefaultSyslogFormatterFile;
use syslog_rs::{SyncSyslog, SyslogApi};
use syslog_rs::{LogFacility, LogStat, Priority, SyslogFile};

pub static SYSLOG: LazyLock<SyncSyslog<DefaultSyslogFormatterFile, SyslogFile>> = LazyLock::new(|| 
    {
        SyncSyslog
            ::<DefaultSyslogFormatterFile, SyslogFile>
            ::openlog_with(
                Some("example"), 
                LogStat::LOG_CONS | LogStat::LOG_NDELAY | LogStat::LOG_PID, 
                LogFacility::LOG_DAEMON,
                SyslogFile::new("/tmp/sync_file.log")
            )
        .unwrap()
    }
);


macro_rules! logdebug 
{
    ($($arg:tt)*) => (
        SYSLOG.syslog(Priority::LOG_DEBUG, format!($($arg)*).into())
    )
}

pub fn main()
{
    logdebug!("test message1!");
    logdebug!("test message2!");
    logdebug!("test message3!");

    thread::sleep(Duration::from_micros(10));

    return;
}

