Replace log with tracing

Tracing is a modern replacement for the log crate that allows for
annotating log messages with the function that they come from.

Signed-off-by: John Nunley <dev@notgull.net>
Closes: #3482
This commit is contained in:
John Nunley 2024-02-25 19:20:39 -08:00 committed by Kirill Chibisov
parent 96172693fe
commit 944347696a
44 changed files with 249 additions and 68 deletions

View file

@ -86,7 +86,7 @@ extern "C" fn preedit_draw_callback(
let chg_range =
call_data.chg_first as usize..(call_data.chg_first + call_data.chg_length) as usize;
if chg_range.start > client_data.text.len() || chg_range.end > client_data.text.len() {
log::warn!(
tracing::warn!(
"invalid chg range: buffer length={}, but chg_first={} chg_lengthg={}",
client_data.text.len(),
call_data.chg_first,

View file

@ -10,9 +10,9 @@ use std::sync::{
Arc,
};
use log::debug;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use tracing::debug;
use super::{ffi, util, XConnection, XError};

View file

@ -18,7 +18,7 @@ use calloop::generic::Generic;
use calloop::EventLoop as Loop;
use calloop::{ping::Ping, Readiness};
use libc::{setlocale, LC_CTYPE};
use log::warn;
use tracing::warn;
use x11rb::connection::RequestConnection;
use x11rb::errors::{ConnectError, ConnectionError, IdsExhausted, ReplyError};
@ -483,7 +483,7 @@ impl<T: 'static> EventLoop<T> {
.dispatch(timeout, &mut self.state)
.map_err(std::io::Error::from)
{
log::error!("Failed to poll for events: {error:?}");
tracing::error!("Failed to poll for events: {error:?}");
let exit_code = error.raw_os_error().unwrap_or(1);
self.set_exit_code(exit_code);
return;
@ -567,7 +567,7 @@ impl<T: 'static> EventLoop<T> {
callback(event, &self.event_processor.target)
}
Some(Err(e)) => {
log::error!("Failed to get activation token: {}", e);
tracing::error!("Failed to get activation token: {}", e);
}
None => {}
}

View file

@ -45,7 +45,7 @@ impl XConnection {
self.flush_requests()?;
Ok(true)
} else {
log::error!("Could not select XKB events: The XKB extension is not initialized!");
tracing::error!("Could not select XKB events: The XKB extension is not initialized!");
Ok(false)
}
}

View file

@ -4,7 +4,7 @@ use super::*;
use crate::platform_impl::platform::x11::monitor;
use crate::{dpi::validate_scale_factor, platform_impl::platform::x11::VideoModeHandle};
use log::warn;
use tracing::warn;
use x11rb::protocol::randr::{self, ConnectionExt as _};
/// Represents values of `WINIT_HIDPI_FACTOR`.
@ -44,7 +44,7 @@ impl XConnection {
Ok(Some(dpi)) => return Some(dpi),
Ok(None) => {}
Err(err) => {
log::warn!("failed to fetch XSettings: {err}");
tracing::warn!("failed to fetch XSettings: {err}");
}
}
}

View file

@ -7,7 +7,7 @@ use std::{
sync::{Arc, Mutex, MutexGuard},
};
use log::{debug, info, warn};
use tracing::{debug, info, warn};
use x11rb::{
connection::Connection,
properties::{WmHints, WmSizeHints, WmSizeHintsSpecification},
@ -1573,7 +1573,7 @@ impl UnownedWindow {
#[cfg(wayland_platform)]
Cursor::Custom(RootCustomCursor {
inner: PlatformCustomCursor::Wayland(_),
}) => log::error!("passed a Wayland cursor to X11 backend"),
}) => tracing::error!("passed a Wayland cursor to X11 backend"),
}
}
@ -1857,7 +1857,7 @@ impl UnownedWindow {
)
.expect_then_ignore_error("Failed to send client message");
if let Err(e) = self.xconn.flush_requests() {
log::error!(
tracing::error!(
"`flush` returned an error when focusing the window. Error was: {}",
e
);

View file

@ -121,7 +121,7 @@ impl XConnection {
let xsettings_screen = Self::new_xsettings_screen(&xcb, default_screen);
if xsettings_screen.is_none() {
log::warn!("error setting XSETTINGS; Xft options won't reload automatically")
tracing::warn!("error setting XSETTINGS; Xft options won't reload automatically")
}
// Fetch atoms.