replaces all daemon prints with logs and enables logging by default (#168)
This commit is contained in:
parent
e7a09dc571
commit
28c57afcd6
6 changed files with 21 additions and 21 deletions
|
@ -82,7 +82,7 @@ impl RawEwwConfig {
|
|||
pub fn merge_includes(mut eww_config: RawEwwConfig, includes: Vec<RawEwwConfig>) -> Result<RawEwwConfig> {
|
||||
let config_path = eww_config.filepath.clone();
|
||||
let log_conflict = |what: &str, conflict: &str, included_path: &std::path::PathBuf| {
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"{} '{}' defined twice (defined in {} and in {})",
|
||||
what,
|
||||
conflict,
|
||||
|
@ -200,7 +200,7 @@ fn parse_variables_block(xml: XmlElement) -> Result<(HashMap<VarName, PrimVal>,
|
|||
// Extends the variables with the predefined variables
|
||||
let inbuilt = crate::config::inbuilt::get_inbuilt_vars();
|
||||
for i in util::extend_safe(&mut script_vars, inbuilt) {
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"script-var '{}' defined twice (defined in your config and in the eww included variables)\nHint: don't define any \
|
||||
varible like any of these: https://elkowar.github.io/eww/main/magic-variables-documenation/",
|
||||
i,
|
||||
|
|
|
@ -33,7 +33,7 @@ impl StateChangeHandler {
|
|||
Ok(resolved_attrs) => {
|
||||
crate::print_result_err!("while updating UI based after state change", &(self.func)(resolved_attrs))
|
||||
}
|
||||
Err(err) => eprintln!("Error while resolving attributes: {:?}", err),
|
||||
Err(err) => log::error!("Error while resolving attributes: {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ pub mod widgets;
|
|||
fn main() {
|
||||
let opts: opts::Opt = opts::Opt::from_env();
|
||||
|
||||
let log_level_filter = if opts.log_debug { log::LevelFilter::Debug } else { log::LevelFilter::Off };
|
||||
let log_level_filter = if opts.log_debug { log::LevelFilter::Debug } else { log::LevelFilter::Info };
|
||||
|
||||
pretty_env_logger::formatted_builder().filter(Some("eww"), log_level_filter).init();
|
||||
pretty_env_logger::formatted_timed_builder().filter(Some("eww"), log_level_filter).init();
|
||||
|
||||
let result: Result<()> = try {
|
||||
let paths = opts
|
||||
|
@ -89,7 +89,7 @@ fn main() {
|
|||
};
|
||||
|
||||
if let Err(e) = result {
|
||||
eprintln!("{:?}", e);
|
||||
log::error!("{:?}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ pub fn initialize_server(paths: EwwPaths) -> Result<()> {
|
|||
);
|
||||
|
||||
simple_signal::set_handler(&[simple_signal::Signal::Int, simple_signal::Signal::Term], move |_| {
|
||||
println!("Shutting down eww daemon...");
|
||||
log::info!("Shutting down eww daemon...");
|
||||
if let Err(e) = crate::application_lifecycle::send_exit() {
|
||||
eprintln!("Failed to send application shutdown event to workers: {:?}", e);
|
||||
log::error!("Failed to send application shutdown event to workers: {:?}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ fn init_async_part(paths: EwwPaths, ui_send: UnboundedSender<app::DaemonCommand>
|
|||
let result = tokio::try_join!(filewatch_join_handle, ipc_server_join_handle, forward_exit_to_app_handle);
|
||||
|
||||
if let Err(e) = result {
|
||||
eprintln!("Eww exiting with error: {:?}", e);
|
||||
log::error!("Eww exiting with error: {:?}", e);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -114,7 +114,7 @@ async fn run_filewatch<P: AsRef<Path>>(config_dir: P, evt_send: UnboundedSender<
|
|||
log::warn!("Error forwarding file update event: {:?}", err);
|
||||
}
|
||||
}
|
||||
Err(e) => eprintln!("Encountered Error While Watching Files: {}", e),
|
||||
Err(e) => log::error!("Encountered Error While Watching Files: {}", e),
|
||||
})?;
|
||||
watcher.watch(&config_dir, notify::RecursiveMode::Recursive)?;
|
||||
|
||||
|
@ -130,9 +130,9 @@ async fn run_filewatch<P: AsRef<Path>>(config_dir: P, evt_send: UnboundedSender<
|
|||
evt_send.send(app::DaemonCommand::ReloadConfigAndCss(daemon_resp_sender))?;
|
||||
tokio::spawn(async move {
|
||||
match daemon_resp_response.recv().await {
|
||||
Some(app::DaemonResponse::Success(_)) => println!("Reloaded config successfully"),
|
||||
Some(app::DaemonResponse::Failure(e)) => eprintln!("Failed to reload config: {}", e),
|
||||
None => eprintln!("No response to reload configuration-reload request"),
|
||||
Some(app::DaemonResponse::Success(_)) => log::info!("Reloaded config successfully"),
|
||||
Some(app::DaemonResponse::Failure(e)) => log::error!("Failed to reload config: {}", e),
|
||||
None => log::error!("No response to reload configuration-reload request"),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ macro_rules! try_logging_errors {
|
|||
($context:expr => $code:block) => {{
|
||||
let result: Result<_> = try { $code };
|
||||
if let Err(err) = result {
|
||||
eprintln!("[{}:{}] Error while {}: {:?}", ::std::file!(), ::std::line!(), $context, err);
|
||||
log::error!("[{}:{}] Error while {}: {:?}", ::std::file!(), ::std::line!(), $context, err);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ macro_rules! try_logging_errors {
|
|||
macro_rules! print_result_err {
|
||||
($context:expr, $result:expr $(,)?) => {{
|
||||
if let Err(err) = $result {
|
||||
eprintln!("[{}:{}] Error {}: {:?}", ::std::file!(), ::std::line!(), $context, err);
|
||||
log::error!("[{}:{}] Error {}: {:?}", ::std::file!(), ::std::line!(), $context, err);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
|
|
@ -29,14 +29,14 @@ pub(self) fn run_command<T: 'static + std::fmt::Display + Send + Sync>(cmd: &str
|
|||
Ok(mut child) => match child.wait_timeout(std::time::Duration::from_millis(200)) {
|
||||
// child timed out
|
||||
Ok(None) => {
|
||||
eprintln!("WARNING: command {} timed out", &cmd);
|
||||
log::error!("WARNING: command {} timed out", &cmd);
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
}
|
||||
Err(err) => eprintln!("Failed to execute command {}: {}", cmd, err),
|
||||
Err(err) => log::error!("Failed to execute command {}: {}", cmd, err),
|
||||
Ok(Some(_)) => {}
|
||||
},
|
||||
Err(err) => eprintln!("Failed to launch child process: {}", err),
|
||||
Err(err) => log::error!("Failed to launch child process: {}", err),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ fn build_builtin_gtk_widget(
|
|||
resolve_widget_attrs(&mut bargs, >k_widget);
|
||||
|
||||
if !bargs.unhandled_attrs.is_empty() {
|
||||
eprintln!(
|
||||
"{}WARN: Unknown attribute used in {}: {}",
|
||||
log::error!(
|
||||
"{}: Unknown attribute used in {}: {}",
|
||||
widget.text_pos.map(|x| format!("{} | ", x)).unwrap_or_default(),
|
||||
widget.name,
|
||||
bargs.unhandled_attrs.iter().map(|x| x.to_string()).join(", ")
|
||||
|
@ -167,7 +167,7 @@ macro_rules! log_errors {
|
|||
($body:expr) => {{
|
||||
let result = try { $body };
|
||||
if let Err(e) = result {
|
||||
eprintln!("WARN: {}", e);
|
||||
log::warn!("{}", e);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue