Skip to main content

routee_compass/plugin/input/default/debug/
debug_plugin.rs

1use 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
11const NAME: &str = "debug";
12
13impl InputPlugin for DebugInputPlugin {
14    fn name(&self) -> &str {
15        NAME
16    }
17
18    fn process(
19        &self,
20        input: &mut serde_json::Value,
21        _search_app: Arc<SearchApp>,
22    ) -> Result<(), InputPluginError> {
23        let json_result = serde_json::to_string_pretty(input);
24        let string = match json_result {
25            Ok(json_string) => json_string,
26            Err(error) => {
27                formatdoc! {r#"
28                    {{
29                        "message": "during debug plugin execution, failed to process incoming query as JSON",
30                        "error": "{}"
31                    }}
32                "#, error}
33            }
34        };
35        log::debug!("{string}");
36        Ok(())
37    }
38}