routee_compass/plugin/input/default/debug/
debug_plugin.rs1use crate::{
2 app::search::SearchApp,
3 plugin::input::{input_plugin::InputPlugin, InputPluginError},
4};
5use indoc::formatdoc;
6use log;
7use std::sync::Arc;
8
9pub struct DebugInputPlugin {}
10
11impl InputPlugin for DebugInputPlugin {
12 fn process(
13 &self,
14 input: &mut serde_json::Value,
15 _search_app: Arc<SearchApp>,
16 ) -> Result<(), InputPluginError> {
17 let json_result = serde_json::to_string_pretty(input);
18 let string = match json_result {
19 Ok(json_string) => json_string,
20 Err(error) => {
21 formatdoc! {r#"
22 {{
23 "message": "during debug plugin execution, failed to process incoming query as JSON",
24 "error": "{}"
25 }}
26 "#, error}
27 }
28 };
29 log::debug!("{string}");
30 Ok(())
31 }
32}