feat: introduce logging in some areas

This commit is contained in:
Jake Stanger 2022-08-25 21:53:57 +01:00
parent 6dcae66570
commit 1e38719996
No known key found for this signature in database
GPG Key ID: C51FC8F9CB0BEA61
4 changed files with 15 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use color_eyre::Result;
use gtk::gdk::Monitor;
use gtk::prelude::*;
use gtk::{Application, ApplicationWindow, Orientation};
use tracing::{debug, info};
pub fn create_bar(
app: &Application,
@ -41,10 +42,12 @@ pub fn create_bar(
win.add(&content);
win.connect_destroy_event(|_, _| {
info!("Shutting down");
gtk::main_quit();
Inhibit(false)
});
debug!("Showing bar");
win.show_all();
Ok(())
@ -104,6 +107,7 @@ fn add_modules(content: &gtk::Box, modules: Vec<ModuleConfig>, info: &ModuleInfo
let widget = $module.into_widget(&info)?;
widget.set_widget_name($name);
content.add(&widget);
debug!("Added module of type {}", $name);
}};
}

View File

@ -110,12 +110,16 @@ fn create_bars(app: &Application, display: &Display, config: &Config) -> Result<
let outputs = serde_json::from_slice::<Vec<SwayOutput>>(&outputs)?;
debug!("Received {} outputs from Sway IPC", outputs.len());
let num_monitors = display.n_monitors();
for i in 0..num_monitors {
let monitor = display.monitor(i).ok_or_else(|| Report::msg("GTK and Sway are reporting a different number of outputs - this is a severe bug and should never happen"))?;
let monitor_name = &outputs.get(i as usize).ok_or_else(|| Report::msg("GTK and Sway are reporting a different set of outputs - this is a severe bug and should never happen"))?.name;
info!("Creating bar on '{}'", monitor_name);
config.monitors.as_ref().map_or_else(
|| create_bar(app, &monitor, monitor_name, config.clone()),
|config| {

View File

@ -59,6 +59,7 @@ impl Module<gtk::Box> for WorkspacesModule {
if self.all_monitors {
workspaces
} else {
trace!("Filtering workspaces to current monitor only");
workspaces
.into_iter()
.filter(|workspace| workspace.output == info.output_name)
@ -72,6 +73,7 @@ impl Module<gtk::Box> for WorkspacesModule {
let (ui_tx, mut ui_rx) = mpsc::channel(32);
trace!("Creating workspace buttons");
for workspace in workspaces {
let item = workspace.as_button(&name_map, &ui_tx);
container.add(&item);
@ -95,9 +97,11 @@ impl Module<gtk::Box> for WorkspacesModule {
});
{
trace!("Setting up sway event handler");
let menubar = container.clone();
let output_name = info.output_name.to_string();
rx.attach(None, move |event| {
debug!("Received workspace event {:?}", event);
match event.change.as_str() {
"focus" => {
let old = event.old.and_then(|old| button_map.get(&old.name));
@ -109,6 +113,8 @@ impl Module<gtk::Box> for WorkspacesModule {
if let Some(new) = new {
new.style_context().add_class("focused");
}
trace!("{:?} {:?}", old, new);
}
"init" => {
if let Some(workspace) = event.current {

View File

@ -133,6 +133,7 @@ impl SwayClient {
}
pub fn ipc(&mut self, command: IpcCommand) -> Result<Vec<u8>> {
debug!("Sending command: {:?}", command);
match self.client.ipc(command) {
Ok(res) => Ok(res),
Err(err) => Err(get_client_error(err)),