chore: cleanup logs

This commit is contained in:
Ashley Wulber 2025-09-12 17:39:37 -04:00 committed by Michael Murphy
parent da11207f12
commit 79bf2cb4f8
16 changed files with 396 additions and 169 deletions

View file

@ -80,7 +80,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
) {
Ok(config_handler) => Some(config_handler),
Err(err) => {
log::error!("failed to create cosmic-comp config handler: {}", err);
tracing::error!("failed to create cosmic-comp config handler: {}", err);
None
}
};
@ -88,7 +88,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
let layouts_opt = match xkb_data::all_keyboard_layouts() {
Ok(ok) => Some(Arc::new(ok)),
Err(err) => {
log::warn!("failed to load keyboard layouts: {}", err);
tracing::warn!("failed to load keyboard layouts: {}", err);
None
}
};
@ -141,8 +141,8 @@ impl<M: From<Message> + Send + 'static> Common<M> {
}
if let Some(comp_config_handler) = &self.comp_config_handler {
match comp_config_handler.set("xkb_config", xkb_config) {
Ok(()) => log::info!("updated cosmic-comp xkb_config"),
Err(err) => log::error!("failed to update cosmic-comp xkb_config: {}", err),
Ok(()) => tracing::info!("updated cosmic-comp xkb_config"),
Err(err) => tracing::error!("failed to update cosmic-comp xkb_config: {}", err),
}
}
}
@ -158,7 +158,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
continue;
};
log::info!("updating wallpaper for {:?}", output_name);
tracing::info!("updating wallpaper for {:?}", output_name);
for (wallpaper_output_name, wallpaper_source) in user_data.bg_state.wallpapers.iter() {
if wallpaper_output_name == output_name {
@ -171,7 +171,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
//TODO: what to do about duplicates?
}
None => {
log::warn!(
tracing::warn!(
"output {}: failed to find wallpaper data for source {:?}",
output_name,
path
@ -182,7 +182,11 @@ impl<M: From<Message> + Send + 'static> Common<M> {
}
BgSource::Color(color) => {
//TODO: support color sources
log::warn!("output {}: unsupported source {:?}", output_name, color);
tracing::warn!(
"output {}: unsupported source {:?}",
output_name,
color
);
}
}
}
@ -234,7 +238,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
}
}
}
log::info!("{:?}", self.active_layouts);
tracing::info!("{:?}", self.active_layouts);
}
}
}
@ -299,7 +303,7 @@ impl<M: From<Message> + Send + 'static> Common<M> {
.get(&surface_id)
.and_then(|id| self.text_input_ids.get(id))
{
log::info!("focus surface found id {:?}", text_input_id);
tracing::info!("focus surface found id {:?}", text_input_id);
return widget::text_input::focus(text_input_id.clone());
}
}

View file

@ -5,6 +5,7 @@ mod ipc;
use crate::wayland::{self, WaylandUpdate};
use cctk::sctk::reexports::calloop;
use color_eyre::eyre::WrapErr;
use cosmic::app::{Core, Settings, Task};
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
use cosmic::iced::event::listen_with;
@ -56,6 +57,9 @@ use std::{
};
use tokio::process::Child;
use tokio::time;
use tracing::metadata::LevelFilter;
use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
use wayland_client::{Proxy, protocol::wl_output::WlOutput};
use zbus::{Connection, proxy};
@ -111,7 +115,35 @@ fn user_data_fallback() -> Vec<UserData> {
}
pub fn main() -> Result<(), Box<dyn Error>> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
color_eyre::install().wrap_err("failed to install color_eyre error handler")?;
let trace = tracing_subscriber::registry();
let env_filter = EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env_lossy();
#[cfg(feature = "systemd")]
if let Ok(journald) = tracing_journald::layer() {
trace
.with(journald)
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
} else {
trace
.with(fmt::layer())
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
warn!("failed to connect to journald")
}
#[cfg(not(feature = "systemd"))]
trace
.with(fmt::layer())
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
crate::localize::localize();
let runtime = tokio::runtime::Builder::new_current_thread()
@ -121,7 +153,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let mut user_datas = match runtime.block_on(user_data_dbus()) {
Ok(ok) => ok,
Err(err) => {
log::error!("failed to load user data from daemon: {}", err);
tracing::error!("failed to load user data from daemon: {}", err);
user_data_fallback()
}
};
@ -163,7 +195,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let read_dir = match fs::read_dir(&session_dir) {
Ok(ok) => ok,
Err(err) => {
log::warn!(
tracing::warn!(
"failed to read session directory {:?}: {:?}",
session_dir,
err
@ -176,7 +208,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let dir_entry = match dir_entry_res {
Ok(ok) => ok,
Err(err) => {
log::warn!(
tracing::warn!(
"failed to read session directory {:?} entry: {:?}",
session_dir,
err
@ -188,7 +220,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let entry = match freedesktop_entry_parser::parse_entry(dir_entry.path()) {
Ok(ok) => ok,
Err(err) => {
log::warn!(
tracing::warn!(
"failed to read session file {:?}: {:?}",
dir_entry.path(),
err
@ -200,7 +232,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let name = match entry.section("Desktop Entry").attr("Name") {
Some(some) => some,
None => {
log::warn!(
tracing::warn!(
"failed to read session file {:?}: no Desktop Entry/Name attribute",
dir_entry.path()
);
@ -211,7 +243,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let exec = match entry.section("Desktop Entry").attr("Exec") {
Some(some) => some,
None => {
log::warn!(
tracing::warn!(
"failed to read session file {:?}: no Desktop Entry/Exec attribute",
dir_entry.path()
);
@ -254,7 +286,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
}
}
None => {
log::warn!(
tracing::warn!(
"failed to parse session file {:?} Exec field {:?}",
dir_entry.path(),
exec
@ -263,10 +295,10 @@ pub fn main() -> Result<(), Box<dyn Error>> {
}
};
log::info!("session {} using command {:?} env {:?}", name, command, env);
tracing::info!("session {} using command {:?} env {:?}", name, command, env);
match sessions.insert(name.to_string(), (command, env)) {
Some(some) => {
log::warn!("session {} overwrote old command {:?}", name, some);
tracing::warn!("session {} overwrote old command {:?}", name, some);
}
None => {}
}
@ -454,16 +486,16 @@ impl App {
if let Some(mut stdin) = p.stdin.take() {
if let Err(err) = stdin.write_all(kdl_doc.as_bytes()).await {
log::error!("Failed to write KDL to stdin: {err:?}");
tracing::error!("Failed to write KDL to stdin: {err:?}");
}
if let Err(err) = stdin.flush().await {
log::error!("Failed to flush stdin: {err:?}");
tracing::error!("Failed to flush stdin: {err:?}");
}
}
log::debug!("executing {task:?}");
tracing::debug!("executing {task:?}");
let status = p.wait().await;
if let Err(err) = status {
log::error!("Randr error: {err:?}");
tracing::error!("Randr error: {err:?}");
}
})
.discard()
@ -1097,7 +1129,7 @@ impl cosmic::Application for App {
Message::OutputEvent(output_event, output) => {
match output_event {
OutputEvent::Created(output_info_opt) => {
log::info!("output {}: created", output.id());
tracing::info!("output {}: created", output.id());
let surface_id = SurfaceId::unique();
let subsurface_id = SurfaceId::unique();
@ -1107,7 +1139,7 @@ impl cosmic::Application for App {
match self.common.surface_ids.insert(output.clone(), surface_id) {
Some(old_surface_id) => {
//TODO: remove old surface?
log::warn!(
tracing::warn!(
"output {}: already had surface ID {:?}",
output.id(),
old_surface_id
@ -1139,11 +1171,11 @@ impl cosmic::Application for App {
.insert(output_name.clone(), text_input_id.clone());
}
None => {
log::warn!("output {}: no output name", output.id());
tracing::warn!("output {}: no output name", output.id());
}
},
None => {
log::warn!("output {}: no output info", output.id());
tracing::warn!("output {}: no output info", output.id());
}
}
@ -1208,7 +1240,7 @@ impl cosmic::Application for App {
]);
}
OutputEvent::Removed => {
log::info!("output {}: removed", output.id());
tracing::info!("output {}: removed", output.id());
match self.common.surface_ids.remove(&output) {
Some(surface_id) => {
self.common.surface_images.remove(&surface_id);
@ -1219,12 +1251,12 @@ impl cosmic::Application for App {
return destroy_layer_surface(surface_id);
}
None => {
log::warn!("output {}: no surface found", output.id());
tracing::warn!("output {}: no surface found", output.id());
}
}
}
OutputEvent::InfoUpdate(_output_info) => {
log::info!("output {}: info update", output.id());
tracing::info!("output {}: info update", output.id());
}
}
}
@ -1319,7 +1351,7 @@ impl cosmic::Application for App {
.map(|uid| self.flags.greeter_config.users.entry(uid))
})
}) else {
log::error!(
tracing::error!(
"Couldn't find user: {:?} {:?}",
self.selected_username.username,
self.selected_username.data_idx,
@ -1328,7 +1360,7 @@ impl cosmic::Application for App {
};
let Some(handler) = self.flags.greeter_config_handler.as_mut() else {
log::error!(
tracing::error!(
"Failed to update config for {} (UID: {}): no config handler",
self.selected_username.username,
user_entry.key()
@ -1339,7 +1371,7 @@ impl cosmic::Application for App {
let uid = *user_entry.key();
self.flags.greeter_config.last_user = Some(uid);
if let Err(err) = handler.set("last_user", &self.flags.greeter_config.last_user) {
log::error!(
tracing::error!(
"Failed to set {:?} as last user: {:?}",
self.flags.greeter_config.last_user,
err
@ -1376,7 +1408,7 @@ impl cosmic::Application for App {
// .greeter_config
// .set_users(&handler, self.flags.greeter_config.users.clone())
if let Err(err) = handler.set("users", &self.flags.greeter_config.users) {
log::error!(
tracing::error!(
"Failed to set {} as last selected session for {} (UID: {}): {:?}",
self.selected_session,
self.selected_username.username,
@ -1421,7 +1453,7 @@ impl cosmic::Application for App {
match crate::logind::reboot().await {
Ok(()) => (),
Err(err) => {
log::error!("failed to reboot: {:?}", err);
tracing::error!("failed to reboot: {:?}", err);
}
}
})
@ -1433,7 +1465,7 @@ impl cosmic::Application for App {
match crate::logind::power_off().await {
Ok(()) => (),
Err(err) => {
log::error!("failed to power off: {:?}", err);
tracing::error!("failed to power off: {:?}", err);
}
}
})
@ -1463,7 +1495,7 @@ impl cosmic::Application for App {
match crate::logind::suspend().await {
Ok(()) => (),
Err(err) => {
log::error!("failed to suspend: {:?}", err);
tracing::error!("failed to suspend: {:?}", err);
}
}
})
@ -1543,7 +1575,7 @@ impl cosmic::Application for App {
if let Some(mut c) = self.accessibility.screen_reader.take() {
return cosmic::task::future::<(), ()>(async move {
if let Err(err) = c.kill().await {
log::error!("Failed to stop screen reader: {err:?}");
tracing::error!("Failed to stop screen reader: {err:?}");
}
})
.discard();
@ -1590,7 +1622,7 @@ impl cosmic::Application for App {
_ = tx.send(Some(t));
}
Err(err) => {
log::error!("{err:?}");
tracing::error!("{err:?}");
_ = tx.send(None);
}
});
@ -1672,7 +1704,7 @@ impl cosmic::Application for App {
.filter_map(|s| match KdlDocument::parse(s) {
Ok(doc) => Some(doc),
Err(err) => {
log::warn!("Invalid output KDL {err:?}");
tracing::warn!("Invalid output KDL {err:?}");
None
}
})
@ -1680,7 +1712,7 @@ impl cosmic::Application for App {
Ok(list) => list,
Err(KdlParseWithError { list, errors }) => {
for err in errors {
log::warn!("KDL output error: {err:?}");
tracing::warn!("KDL output error: {err:?}");
}
list
}
@ -1709,13 +1741,13 @@ impl cosmic::Application for App {
if let Some(list) = list {
tasks.push(self.exec_randr(list))
} else {
log::warn!("Failed to apply user display config");
tracing::warn!("Failed to apply user display config");
}
return Task::batch(tasks);
}
Err(err) => {
log::error!("Randr error: {err}");
tracing::error!("Randr error: {err}");
}
},
Message::RepositionMenu(id, size) => {
@ -1724,7 +1756,7 @@ impl cosmic::Application for App {
.iter()
.find_map(|(p, s)| (*p == id).then_some(s))
else {
log::error!("Failed to find subsurface menu id");
tracing::error!("Failed to find subsurface menu id");
return Task::none();
};
let loc = if size.width > 800. {

View file

@ -31,7 +31,7 @@ pub fn subscription() -> Subscription<Message> {
let mut stream = match UnixStream::connect(&socket_path).await {
Ok(stream) => stream,
Err(why) => {
log::error!("greetd IPC socket connection failed: {why:?}");
tracing::error!("greetd IPC socket connection failed: {why:?}");
_ = sender.send(Message::Socket(SocketState::Error(Arc::new(why))));
break;
@ -42,7 +42,7 @@ pub fn subscription() -> Subscription<Message> {
while let Some(request) = rx.recv().await {
if let Err(why) = request.write_to(&mut stream).await {
log::error!("error writing to GREETD_SOCK stream: {why:?}");
tracing::error!("error writing to GREETD_SOCK stream: {why:?}");
break;
}
@ -96,7 +96,7 @@ pub fn subscription() -> Subscription<Message> {
match request {
greetd_ipc::Request::CancelSession => {
// Do not send errors for cancel session to gui
log::warn!(
tracing::warn!(
"error while cancelling session: {}",
description
);
@ -123,7 +123,7 @@ pub fn subscription() -> Subscription<Message> {
_ = sender.send(Message::Exit).await;
}
greetd_ipc::Request::CancelSession => {
log::info!("greetd IPC session canceled");
tracing::info!("greetd IPC session canceled");
// Reconnect to socket
break;
}
@ -131,13 +131,13 @@ pub fn subscription() -> Subscription<Message> {
}
}
Err(err) => {
log::error!("failed to read socket: {:?}", err);
tracing::error!("failed to read socket: {:?}", err);
break;
}
}
}
log::info!("reconnecting to greetd IPC socket");
tracing::info!("reconnecting to greetd IPC socket");
interval.tick().await;
}

View file

@ -1,6 +1,7 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: GPL-3.0-only
use color_eyre::eyre::WrapErr;
use cosmic::app::{Core, Settings, Task};
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::Gravity;
use cosmic::iced::{Point, Rectangle, Size};
@ -33,6 +34,9 @@ use std::{
sync::Arc,
};
use tokio::{sync::mpsc, task};
use tracing::level_filters::LevelFilter;
use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
use wayland_client::{Proxy, protocol::wl_output::WlOutput};
use crate::{
@ -47,7 +51,35 @@ fn lockfile_opt() -> Option<PathBuf> {
}
pub fn main(user: pwd::Passwd) -> Result<(), Box<dyn std::error::Error>> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
color_eyre::install().wrap_err("failed to install color_eyre error handler")?;
let trace = tracing_subscriber::registry();
let env_filter = EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env_lossy();
#[cfg(feature = "systemd")]
if let Ok(journald) = tracing_journald::layer() {
trace
.with(journald)
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
} else {
trace
.with(fmt::layer())
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
warn!("failed to connect to journald")
}
#[cfg(not(feature = "systemd"))]
trace
.with(fmt::layer())
.with(env_filter)
.try_init()
.wrap_err("failed to initialize logger")?;
crate::localize::localize();
@ -74,11 +106,11 @@ pub fn pam_thread(username: String, conversation: Conversation) -> Result<(), pa
let mut context = pam_client::Context::new("cosmic-greeter", Some(&username), conversation)?;
// Authenticate the user (ask for password, 2nd-factor token, fingerprint, etc.)
log::info!("authenticate");
tracing::info!("authenticate");
context.authenticate(pam_client::Flag::NONE)?;
// Validate the account (is not locked, expired, etc.)
log::info!("acct_mgmt");
tracing::info!("acct_mgmt");
context.acct_mgmt(pam_client::Flag::NONE)?;
Ok(())
@ -96,7 +128,7 @@ impl Conversation {
secret: bool,
) -> Result<CString, pam_client::ErrorCode> {
let prompt = prompt_c.to_str().map_err(|err| {
log::error!("failed to convert prompt to UTF-8: {:?}", err);
tracing::error!("failed to convert prompt to UTF-8: {:?}", err);
pam_client::ErrorCode::CONV_ERR
})?;
@ -108,24 +140,24 @@ impl Conversation {
.await
})
.map_err(|err| {
log::error!("failed to send prompt: {:?}", err);
tracing::error!("failed to send prompt: {:?}", err);
pam_client::ErrorCode::CONV_ERR
})?;
let value = self.value_rx.blocking_recv().ok_or_else(|| {
log::error!("failed to receive value: channel closed");
tracing::error!("failed to receive value: channel closed");
pam_client::ErrorCode::CONV_ERR
})?;
CString::new(value).map_err(|err| {
log::error!("failed to convert value to C string: {:?}", err);
tracing::error!("failed to convert value to C string: {:?}", err);
pam_client::ErrorCode::CONV_ERR
})
}
fn message(&mut self, prompt_c: &CStr) -> Result<(), pam_client::ErrorCode> {
let prompt = prompt_c.to_str().map_err(|err| {
log::error!("failed to convert prompt to UTF-8: {:?}", err);
tracing::error!("failed to convert prompt to UTF-8: {:?}", err);
pam_client::ErrorCode::CONV_ERR
})?;
@ -137,7 +169,7 @@ impl Conversation {
.await
})
.map_err(|err| {
log::error!("failed to send prompt: {:?}", err);
tracing::error!("failed to send prompt: {:?}", err);
pam_client::ErrorCode::CONV_ERR
})
}
@ -145,29 +177,29 @@ impl Conversation {
impl pam_client::ConversationHandler for Conversation {
fn prompt_echo_on(&mut self, prompt_c: &CStr) -> Result<CString, pam_client::ErrorCode> {
log::info!("prompt_echo_on {:?}", prompt_c);
tracing::info!("prompt_echo_on {:?}", prompt_c);
self.prompt_value(prompt_c, false)
}
fn prompt_echo_off(&mut self, prompt_c: &CStr) -> Result<CString, pam_client::ErrorCode> {
log::info!("prompt_echo_off {:?}", prompt_c);
tracing::info!("prompt_echo_off {:?}", prompt_c);
self.prompt_value(prompt_c, true)
}
fn text_info(&mut self, prompt_c: &CStr) {
log::info!("text_info {:?}", prompt_c);
tracing::info!("text_info {:?}", prompt_c);
match self.message(prompt_c) {
Ok(()) => (),
Err(err) => {
log::warn!("failed to send text_info: {:?}", err);
tracing::warn!("failed to send text_info: {:?}", err);
}
}
}
fn error_msg(&mut self, prompt_c: &CStr) {
//TODO: treat error type differently?
log::info!("error_msg {:?}", prompt_c);
tracing::info!("error_msg {:?}", prompt_c);
match self.message(prompt_c) {
Ok(()) => (),
Err(err) => {
log::warn!("failed to send error_msg: {:?}", err);
tracing::warn!("failed to send error_msg: {:?}", err);
}
}
}
@ -226,7 +258,7 @@ impl Drop for State {
fn drop(&mut self) {
// Abort the locked task when the state is changed.
if let Self::Locked { task_handle } = self {
log::info!("dropping lockscreen tasks");
tracing::info!("dropping lockscreen tasks");
task_handle.abort();
}
}
@ -542,7 +574,7 @@ impl cosmic::Application for App {
let task = if cfg!(feature = "logind") {
if already_locked {
// Recover previously locked state
log::info!("recovering previous locked state");
tracing::info!("recovering previous locked state");
app.state = State::Locking;
lock()
} else {
@ -551,7 +583,7 @@ impl cosmic::Application for App {
}
} else {
// When logind feature not used, lock immediately
log::info!("locking immediately");
tracing::info!("locking immediately");
app.state = State::Locking;
lock()
};
@ -569,7 +601,7 @@ impl cosmic::Application for App {
Message::OutputEvent(output_event, output) => {
match output_event {
OutputEvent::Created(output_info_opt) => {
log::info!("output {}: created", output.id());
tracing::info!("output {}: created", output.id());
let surface_id = SurfaceId::unique();
let subsurface_id = SurfaceId::unique();
@ -578,7 +610,7 @@ impl cosmic::Application for App {
self.common.surface_ids.insert(output.clone(), surface_id)
{
//TODO: remove old surface?
log::warn!(
tracing::warn!(
"output {}: already had surface ID {:?}",
output.id(),
old_surface_id
@ -614,11 +646,11 @@ impl cosmic::Application for App {
.insert(output_name.clone(), text_input_id.clone());
}
None => {
log::warn!("output {}: no output name", output.id());
tracing::warn!("output {}: no output name", output.id());
}
},
None => {
log::warn!("output {}: no output info", output.id());
tracing::warn!("output {}: no output info", output.id());
}
}
@ -672,7 +704,7 @@ impl cosmic::Application for App {
}
}
OutputEvent::Removed => {
log::info!("output {}: removed", output.id());
tracing::info!("output {}: removed", output.id());
match self.common.surface_ids.remove(&output) {
Some(surface_id) => {
self.common.surface_images.remove(&surface_id);
@ -686,7 +718,7 @@ impl cosmic::Application for App {
}
}
None => {
log::warn!("output {}: no surface found", output.id());
tracing::warn!("output {}: no surface found", output.id());
}
}
}
@ -711,14 +743,14 @@ impl cosmic::Application for App {
.subsurface_rects
.insert(output.clone(), Rectangle::new(loc, sub_size));
log::info!("output {}: info update", output.id());
tracing::info!("output {}: info update", output.id());
}
}
}
Message::SessionLockEvent(session_lock_event) => match session_lock_event {
SessionLockEvent::Focused(..) => {}
SessionLockEvent::Locked => {
log::info!("session locked");
tracing::info!("session locked");
if matches!(self.state, State::Locked { .. }) {
return Task::none();
}
@ -764,7 +796,7 @@ impl cosmic::Application for App {
match pam_res {
Ok(()) => {
log::info!("successfully authenticated");
tracing::info!("successfully authenticated");
msg_tx
.send(cosmic::Action::App(Message::Unlock))
.await
@ -772,7 +804,7 @@ impl cosmic::Application for App {
break;
}
Err(err) => {
log::warn!("authentication error: {}", err);
tracing::warn!("authentication error: {}", err);
msg_tx
.send(cosmic::Action::App(Message::Error(
err.to_string(),
@ -838,13 +870,13 @@ impl cosmic::Application for App {
cosmic::app::Action::Surface(msg),
)));
} else {
log::error!("no rectangle for subsurface...");
tracing::error!("no rectangle for subsurface...");
}
}
return Task::batch(commands);
}
SessionLockEvent::Unlocked => {
log::info!("session unlocked");
tracing::info!("session unlocked");
self.state = State::Unlocked;
let mut commands = Vec::new();
@ -883,7 +915,7 @@ impl cosmic::Application for App {
}
Message::Inhibit(inhibit) => match self.state {
State::Locked { .. } => {
log::info!("no need to inhibit sleep when already locked");
tracing::info!("no need to inhibit sleep when already locked");
}
_ => {
self.inhibit_opt = Some(inhibit);
@ -910,14 +942,14 @@ impl cosmic::Application for App {
Message::Channel(value_tx)
});
}
None => log::warn!("tried to submit when value_tx_opt not set"),
None => tracing::warn!("tried to submit when value_tx_opt not set"),
}
}
Message::Suspend => {
#[cfg(feature = "logind")]
return cosmic::Task::future(async move { crate::logind::suspend().await.err() })
.and_then(|err| {
log::error!("failed to suspend: {:?}", err);
tracing::error!("failed to suspend: {:?}", err);
cosmic::task::message(cosmic::Action::App(Message::Error(err.to_string())))
});
}
@ -929,7 +961,7 @@ impl cosmic::Application for App {
}
Message::Lock => match self.state {
State::Unlocked => {
log::info!("session locking");
tracing::info!("session locking");
self.state = State::Locking;
// Clear errors
self.common.error_opt = None;
@ -938,23 +970,23 @@ impl cosmic::Application for App {
// Try to create lockfile when locking
if let Some(ref lockfile) = self.flags.lockfile_opt {
if let Err(err) = fs::File::create(lockfile) {
log::warn!("failed to create lockfile {:?}: {}", lockfile, err);
tracing::warn!("failed to create lockfile {:?}: {}", lockfile, err);
}
}
// Tell compositor to lock
return lock();
}
State::Unlocking => {
log::info!("session still unlocking");
tracing::info!("session still unlocking");
}
State::Locking | State::Locked { .. } => {
log::info!("session already locking or locked");
tracing::info!("session already locking or locked");
}
},
Message::Unlock => {
match self.state {
State::Locked { .. } => {
log::info!("sessing unlocking");
tracing::info!("sessing unlocking");
self.state = State::Unlocking;
// Clear errors
self.common.error_opt = None;
@ -963,7 +995,7 @@ impl cosmic::Application for App {
// Try to delete lockfile when unlocking
if let Some(ref lockfile) = self.flags.lockfile_opt {
if let Err(err) = fs::remove_file(lockfile) {
log::warn!("failed to remove lockfile {:?}: {}", lockfile, err);
tracing::warn!("failed to remove lockfile {:?}: {}", lockfile, err);
}
}
@ -983,10 +1015,10 @@ impl cosmic::Application for App {
return Task::batch(commands);
}
State::Locking => {
log::info!("session still locking");
tracing::info!("session still locking");
}
State::Unlocking | State::Unlocked => {
log::info!("session already unlocking or unlocked");
tracing::info!("session already unlocking or unlocked");
}
}
}
@ -1032,7 +1064,7 @@ impl cosmic::Application for App {
)
.map(|res| {
if !res.errors.is_empty() {
log::info!("errors loading background state: {:?}", res.errors);
tracing::info!("errors loading background state: {:?}", res.errors);
}
Message::BackgroundState(res.config)
}),
@ -1047,7 +1079,7 @@ impl cosmic::Application for App {
)
.map(|res| {
if !res.errors.is_empty() {
log::info!("errors loading background state: {:?}", res.errors);
tracing::info!("errors loading background state: {:?}", res.errors);
}
Message::TimeAppletConfig(res.config)
}),

View file

@ -52,7 +52,7 @@ pub fn subscription() -> Subscription<Message> {
match handler(&mut msg_tx).await {
Ok(()) => {}
Err(err) => {
log::warn!("logind error: {}", err);
tracing::warn!("logind error: {}", err);
//TODO: send error
}
}
@ -89,13 +89,13 @@ pub async fn handler(msg_tx: &mut mpsc::Sender<Message>) -> Result<(), Box<dyn E
Some(signal) => match signal.args() {
Ok(args) => {
if args.start {
log::info!("logind prepare for sleep");
tracing::info!("logind prepare for sleep");
if let Some(inhibit) = inhibit_opt.take() {
msg_tx.send(Message::Inhibit(Arc::new(inhibit))).await?;
}
msg_tx.send(Message::Lock).await?;
} else {
log::info!("logind resume");
tracing::info!("logind resume");
if inhibit_opt.is_none() {
inhibit_opt = Some(inhibit(&manager).await?);
}
@ -104,19 +104,19 @@ pub async fn handler(msg_tx: &mut mpsc::Sender<Message>) -> Result<(), Box<dyn E
}
},
Err(err) => {
log::warn!("logind prepare to sleep invalid data: {}", err);
tracing::warn!("logind prepare to sleep invalid data: {}", err);
}
},
None => {
log::warn!("logind prepare to sleep missing data");
tracing::warn!("logind prepare to sleep missing data");
}
}
},
_ = lock.next() => {
log::info!("logind lock");
tracing::info!("logind lock");
msg_tx.send(Message::Lock).await?;
}, _ = unlock.next() => {
log::info!("logind unlock");
tracing::info!("logind unlock");
msg_tx.send(Message::Unlock).await?;
});

View file

@ -42,7 +42,7 @@ pub fn subscription() -> Subscription<Option<&'static str>> {
match handler(&mut msg_tx).await {
Ok(()) => {}
Err(err) => {
log::warn!("networkmanager error: {}", err);
tracing::warn!("networkmanager error: {}", err);
//TODO: send error
}
}

View file

@ -47,7 +47,7 @@ impl Time {
let locale = match get_local() {
Ok(locale) => locale,
Err(e) => {
log::error!("can't get locale {e}");
tracing::error!("can't get locale {e}");
Locale::default()
}
};
@ -136,7 +136,7 @@ pub fn tz_updates() -> Task<chrono_tz::Tz> {
Task::stream(async_fn_stream::fn_stream(|emitter| async move {
loop {
if let Err(err) = tz_stream(&emitter).await {
log::error!("{err:?}");
tracing::error!("{err:?}");
}
_ = time::sleep(Duration::from_secs(60)).await;
}

View file

@ -15,7 +15,7 @@ pub fn subscription() -> Subscription<Option<(String, f64)>> {
match handler(&mut msg_tx).await {
Ok(()) => {}
Err(err) => {
log::warn!("upower error: {}", err);
tracing::warn!("upower error: {}", err);
//TODO: send error
}
}