diff --git a/Cargo.toml b/Cargo.toml index ef9aa10..1ad7862 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lolicron" version = "0.1.0" -authors = ["Avril "] +authors = ["Avril ", "Mx. Package Install "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/log.rs b/src/log.rs index 07e03cd..e00ff67 100644 --- a/src/log.rs +++ b/src/log.rs @@ -192,6 +192,44 @@ impl Logger }; } + + +#[macro_export] macro_rules! status { + ($obj:expr) => { + { + struct Status; + use std::{ + borrow::Borrow, + fmt, + }; + impl Borrow<$crate::log::Level> for Status { + fn borrow(&self) -> &$crate::log::Level + { + &$crate::log::Level::Debug + } + } + impl fmt::Display for Status + { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result + { + use recolored::Colorize; + write!(f, "{}", "Status".blue()) + } + } + + impl $crate::log::AsLevel for Status{} + + let stdout = std::io::stdout(); + let stdout = stdout.lock(); + $crate::log::Logger::global().println(stdout, Status, $obj).expect("i/o error"); + } + }; + ($fmt:literal, $($args:expr),*) => { + status!(format!($fmt, $($args,)*)); + }; +} + + #[macro_export] macro_rules! info { ($obj:expr) => { { diff --git a/src/main.rs b/src/main.rs index 845cb47..55d49cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ use tokio::{ }, task, }; +use lazy_static::lazy_static; mod util; use util::*; @@ -60,13 +61,34 @@ async fn do_thing_every() -> Result<(mpsc::Sender<()>, task::JoinHandle<()>), Bo Ok((tx, handle)) } +fn print_stats() +{ + lazy_static! { + static ref AUTHORS: String = env!("CARGO_PKG_AUTHORS").replace( ":", ", "); + }; + + status!("This is the lolicron daemon version {} by {}", env!("CARGO_PKG_VERSION"), &AUTHORS[..]); + status!("---"); + status!("Compiled with:"); + #[cfg(nightly)] status!(" +nightly"); + #[cfg(debug_assertions)] status!(" +debug_assertions"); + status!("features:"); + #[cfg(feature="threaded")] status!(" +threaded"); + status!(""); + status!("GPl'd with <3"); + status!("Please enjoy"); + status!("---"); +} + #[tokio::main] async fn main() -> Result<(), Box> { log::init(log::Level::Debug); - - debug!("Initialised"); + + debug!("Logger initialised"); + print_stats(); + let oneesan = live::watch("."); { @@ -81,8 +103,7 @@ async fn main() -> Result<(), Box> { oneesan.shutdown().await.expect("oneesan panic"); println!("{:?}", config::parse_global_single("example.rori").await.expect("Waaaaaah")); - dangerous!("Wheeeee"); - + //let (mut tx, h) = do_thing_every().await?; // loop { diff --git a/src/util.rs b/src/util.rs index f5c6c8d..06ba526 100644 --- a/src/util.rs +++ b/src/util.rs @@ -98,7 +98,7 @@ where F:FnOnce(T) if #[cfg(nightly)] { self.0.get_ref() } else { - std::mem::transmute::<_,&'a T>(self.0.as_ptr()) + std::mem::transmute(self.0.as_ptr()) } } } @@ -113,7 +113,7 @@ where F:FnOnce(T) if #[cfg(nightly)] { self.0.get_mut() } else { - std::mem::transmute::<_,&'a T>(self.0.as_mut_ptr()) + std::mem::transmute(self.0.as_mut_ptr()) } } }