conditionally disable debug logging

master
Avril 4 years ago
parent ec0bf8e24a
commit cc31004e52
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -8,21 +8,28 @@ edition = "2018"
[features]
default = ["threaded",
"watcher_timeout"]
"watcher_timeout",
"debug_logger"]
# Run with threads (TODO: rename to `threads`. What does this do?? We need `rt-threaded` for fs watcher to work...)
threaded = []
threaded = ["tokio/rt-threaded"]
# Enable `Debug` log level printing option at runtime in release mode.
debug_logger = []
# Hot-reload config files
watcher = ["threaded"]
# FS watcher will have infinite backlog, instead of ignoring if it goes over its backlog.
# This can help DoS, but potentially cause OOM.
watcher_unlimited = []
watcher_unlimited = ["watcher"]
# FS watcher hooks have a defined timeout
# This can help with DoS, and hooks that hog resources
watcher_timeout = []
watcher_timeout = ["watcher"]
[dependencies]
tokio = {version = "0.2", features=["time", "macros", "io-driver", "sync", "rt-core", "rt-threaded", "fs"]}
tokio = {version = "0.2", features=["time", "macros", "io-driver", "sync", "rt-core", "fs"]}
notify = "5.0.0-pre.3"
futures= "0.3"
sexp = "1.1"

@ -13,6 +13,7 @@
//! # TODO
//! - Make child not panic if `watch()` is called on non-existant path
//! - Change hook from just string path prefix to pattern match with optional regex capability. (For finding and dispatching on global/local config files differently)
#![allow(unused_imports)] // For when hotreload feature disabled
use super::*;
use std::{
@ -241,6 +242,7 @@ impl Oneesan
}
}
#[cfg(feature="watcher")]
/// Start watching this path for changes of files
pub fn watch(path: impl AsRef<Path>) -> Oneesan
{

@ -312,7 +312,7 @@ impl Logger
Ok(())
}
}
#[cfg(any(debug_assertions,feature="debug_logger"))]
#[macro_export] macro_rules! debug {
($obj:expr) => {
{
@ -326,8 +326,14 @@ impl Logger
};
}
#[cfg(not(any(debug_assertions,feature="debug_logger")))]
#[macro_export] macro_rules! debug {
($obj:expr) => {{}};
($fmt:literal, $($args:expr),*) => {{}};
}
#[cfg(any(debug_assertions,feature="debug_logger"))]
#[macro_export] macro_rules! status {
($obj:expr) => {
{
@ -363,6 +369,11 @@ impl Logger
};
}
#[cfg(not(any(debug_assertions,feature="debug_logger")))]
#[macro_export] macro_rules! status {
($obj:expr) => {{}};
($fmt:literal, $($args:expr),*) => {{}};
}
#[macro_export] macro_rules! info {
($obj:expr) => {

@ -26,6 +26,7 @@ mod interval;
mod config;
mod live;
mod context;
mod job;
@ -80,6 +81,7 @@ fn print_stats()
static ref BUILD_IDENT: recolored::ColoredString = "release".bright_red();
}
#[allow(unused_imports)]
use std::ops::Deref;
status!("This is the lolicron daemon version {} by {} ({} build)", env!("CARGO_PKG_VERSION"), &AUTHORS[..], BUILD_IDENT.deref());
status!("---");
@ -92,6 +94,12 @@ fn print_stats()
#[cfg(feature="threaded")] status!(" +threaded".red());
#[cfg(not(feature="threaded"))] status!(" -threaded".bright_blue());
#[cfg(feature="watcher")] status!(" +watcher".red());
#[cfg(not(feature="watcher"))] status!(" -watcher".bright_blue());
#[cfg(feature="debug_logger")] status!(" +debug_logger".red());
#[cfg(not(feature="debug_logger"))] status!(" -debug_logger".bright_blue());
#[cfg(feature="watcher_unlimited")] status!(" +watcher_unlimited".bright_red());
#[cfg(not(feature="watcher_unlimited"))] status!(" -watcher_unlimited".blue());
@ -111,21 +119,24 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::init(log::Level::Debug);
debug!("Logger initialised");
debug!("Logger initialised"); //TODO: Parse config first
print_stats();
let oneesan = live::watch(".");
#[cfg(feature="watcher")]
{
let mut recv = oneesan.hook("src/main.rs", live::filter::ALL).await;
while let Some(event) = recv.recv().await
let oneesan = live::watch(".");
{
important!("Got ev {:?}", event);
break;
let mut recv = oneesan.hook("src/main.rs", live::filter::ALL).await;
while let Some(event) = recv.recv().await
{
important!("Got ev {:?}", event);
break;
}
}
}
oneesan.shutdown().await.expect("oneesan panic");
oneesan.shutdown().await.expect("oneesan panic");
}
println!("{:?}", config::parse_global_single("example.rori").await.expect("Waaaaaah"));

Loading…
Cancel
Save