Files
Graphite/editor/src/messages/debug/debug_message_handler.rs
T
Mohd MohsinandKeavon Chambers 00236c8136 Generate a visualization of the editor's hierarchical message system tree (#2499)
* Feat: implement the hierarchical tree for visualization

* rename HierarchicalTree trait function

* feat: change the HierarchicalTree from String to DebugMessageTree struct

* Nits

* feat: impliment proc macro to extract field from messagedata structs

* update the hierarchical-tree for hanlder data

* feat: added message handler struct to hierarchical tree

* feat: add the line number to message handler struct

* feat: added handler path to tree and NITS

* clean the white spaces in type string

* fixes some white spaces

* feat: added path to message enum in hierarchical tree

* feat: add file creation of hierarchical message system tree

* cleanup

* Code review

* Add todo comment for deferred change

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2025-07-08 19:13:51 -07:00

51 lines
1.5 KiB
Rust

use super::utility_types::MessageLoggingVerbosity;
use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DebugMessageHandler {
pub message_logging_verbosity: MessageLoggingVerbosity,
}
#[message_handler_data]
impl MessageHandler<DebugMessage, ()> for DebugMessageHandler {
fn process_message(&mut self, message: DebugMessage, responses: &mut VecDeque<Message>, _data: ()) {
match message {
DebugMessage::ToggleTraceLogs => {
if log::max_level() == log::LevelFilter::Debug {
log::set_max_level(log::LevelFilter::Trace);
} else {
log::set_max_level(log::LevelFilter::Debug);
}
// Refresh the checkmark beside the menu entry for this
responses.add(MenuBarMessage::SendLayout);
}
DebugMessage::MessageOff => {
self.message_logging_verbosity = MessageLoggingVerbosity::Off;
// Refresh the checkmark beside the menu entry for this
responses.add(MenuBarMessage::SendLayout);
}
DebugMessage::MessageNames => {
self.message_logging_verbosity = MessageLoggingVerbosity::Names;
// Refresh the checkmark beside the menu entry for this
responses.add(MenuBarMessage::SendLayout);
}
DebugMessage::MessageContents => {
self.message_logging_verbosity = MessageLoggingVerbosity::Contents;
// Refresh the checkmark beside the menu entry for this
responses.add(MenuBarMessage::SendLayout);
}
}
}
advertise_actions!(DebugMessageDiscriminant;
ToggleTraceLogs,
MessageOff,
MessageNames,
MessageContents,
);
}