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:
parent
96172693fe
commit
944347696a
44 changed files with 249 additions and 68 deletions
|
|
@ -471,10 +471,10 @@ fn window_activation_hack(app: &NSApplication) {
|
|||
// This way we preserve the user's desired initial visibility status
|
||||
// TODO: Also filter on the type/"level" of the window, and maybe other things?
|
||||
if window.isVisible() {
|
||||
log::trace!("Activating visible window");
|
||||
tracing::trace!("Activating visible window");
|
||||
window.makeKeyAndOrderFront(None);
|
||||
} else {
|
||||
log::trace!("Skipping activating invisible window");
|
||||
tracing::trace!("Skipping activating invisible window");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ unsafe fn try_cursor_from_selector(sel: Sel) -> Option<Id<NSCursor>> {
|
|||
let cursor: Id<NSCursor> = unsafe { msg_send_id![cls, performSelector: sel] };
|
||||
Some(cursor)
|
||||
} else {
|
||||
log::warn!("cursor `{sel}` appears to be invalid");
|
||||
tracing::warn!("cursor `{sel}` appears to be invalid");
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ pub fn get_modifierless_char(scancode: u16) -> Key {
|
|||
unsafe {
|
||||
input_source = ffi::TISCopyCurrentKeyboardLayoutInputSource();
|
||||
if input_source.is_null() {
|
||||
log::error!("`TISCopyCurrentKeyboardLayoutInputSource` returned null ptr");
|
||||
tracing::error!("`TISCopyCurrentKeyboardLayoutInputSource` returned null ptr");
|
||||
return Key::Unidentified(NativeKey::MacOS(scancode));
|
||||
}
|
||||
let layout_data =
|
||||
ffi::TISGetInputSourceProperty(input_source, ffi::kTISPropertyUnicodeKeyLayoutData);
|
||||
if layout_data.is_null() {
|
||||
CFRelease(input_source as *mut c_void);
|
||||
log::error!("`TISGetInputSourceProperty` returned null ptr");
|
||||
tracing::error!("`TISGetInputSourceProperty` returned null ptr");
|
||||
return Key::Unidentified(NativeKey::MacOS(scancode));
|
||||
}
|
||||
layout = CFDataGetBytePtr(layout_data as CFDataRef) as *const ffi::UCKeyboardLayout;
|
||||
|
|
@ -71,7 +71,7 @@ pub fn get_modifierless_char(scancode: u16) -> Key {
|
|||
CFRelease(input_source as *mut c_void);
|
||||
}
|
||||
if translate_result != 0 {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"`UCKeyTranslate` returned with the non-zero value: {}",
|
||||
translate_result
|
||||
);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl EventHandler {
|
|||
*data = None;
|
||||
}
|
||||
Ok(None) => {
|
||||
log::error!("tried to clear handler, but no handler was set");
|
||||
tracing::error!("tried to clear handler, but no handler was set");
|
||||
}
|
||||
Err(_) => {
|
||||
// Note: This is not expected to ever happen, this
|
||||
|
|
@ -125,7 +125,7 @@ impl EventHandler {
|
|||
// `NSApplication`, our app delegate and this handler are all
|
||||
// global state and so it's not impossible that we could get
|
||||
// an event after the application has exited the `EventLoop`.
|
||||
log::error!("tried to run event handler, but no handler was set");
|
||||
tracing::error!("tried to run event handler, but no handler was set");
|
||||
}
|
||||
Err(_) => {
|
||||
// Prevent re-entrancy.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use icrate::Foundation::{NSNotFound, NSRange, NSUInteger};
|
||||
use log::trace;
|
||||
use tracing::trace;
|
||||
|
||||
pub const EMPTY_RANGE: NSRange = NSRange {
|
||||
location: NSNotFound as NSUInteger,
|
||||
|
|
@ -20,7 +20,7 @@ pub(crate) struct TraceGuard {
|
|||
impl TraceGuard {
|
||||
#[inline]
|
||||
pub(crate) fn new(module_path: &'static str, called_from_fn: &'static str) -> Self {
|
||||
trace!(target: module_path, "Triggered `{}`", called_from_fn);
|
||||
trace!(target = module_path, "Triggered `{}`", called_from_fn);
|
||||
Self {
|
||||
module_path,
|
||||
called_from_fn,
|
||||
|
|
@ -31,6 +31,10 @@ impl TraceGuard {
|
|||
impl Drop for TraceGuard {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
trace!(target: self.module_path, "Completed `{}`", self.called_from_fn);
|
||||
trace!(
|
||||
target = self.module_path,
|
||||
"Completed `{}`",
|
||||
self.called_from_fn
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ declare_class!(
|
|||
// Leave the Preedit self.ivars()
|
||||
self.ivars().ime_state.set(ImeState::Ground);
|
||||
} else {
|
||||
log::warn!("Expected to have IME enabled when receiving unmarkText");
|
||||
tracing::warn!("Expected to have IME enabled when receiving unmarkText");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue