Add macros for logging.

This commit is contained in:
2026-02-22 10:09:53 -05:00
parent e5f77ef51c
commit 779872b2f6
21 changed files with 246 additions and 79 deletions

View File

@@ -3,7 +3,8 @@
// SPDX-License-Identifier: GNU General Public License v3.0 or later
use crate::tui::component::{Action, Component, ComponentState, Focus, FocusState};
use log::{LevelFilter, trace};
use libclide_macros::log_id;
use log::LevelFilter;
use ratatui::buffer::Buffer;
use ratatui::crossterm::event::{Event, KeyCode, KeyEvent};
use ratatui::layout::Rect;
@@ -13,16 +14,15 @@ use tui_logger::{TuiLoggerLevelOutput, TuiLoggerSmartWidget, TuiWidgetEvent, Tui
/// Any log written as info!(target:self.id(), "message") will work with this logger.
/// The logger is bound to info!, debug!, error!, trace! macros within Tui::new().
#[log_id]
pub struct Logger {
state: TuiWidgetState,
pub(crate) component_state: ComponentState,
}
impl Logger {
pub const ID: &str = "Logger";
pub fn new() -> Self {
trace!(target:Self::ID, "Building {}", Self::ID);
libclide::trace!(target:Self::ID, "Building {}", Self::ID);
let state = TuiWidgetState::new();
state.transition(TuiWidgetEvent::HideKey);
Self {