Skip to content

Commit

Permalink
Change how output is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
pvshvp-oss committed May 12, 2024
1 parent 1a2356e commit 9155671
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 19 deletions.
11 changes: 4 additions & 7 deletions paxy/src/app/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,9 @@ pub fn init_log(config: &config::ConfigTemplate) -> Result<Handle, Error> {
.console_output_format
.mode
{
ui::ConsoleOutputMode::Plain => logging_handle
.switch_to_plain()?,
ui::ConsoleOutputMode::Json => logging_handle
.switch_to_json()?,
ui::ConsoleOutputMode::Test => logging_handle
.switch_to_test()?,
ui::ConsoleOutputMode::Plain => logging_handle.switch_to_plain()?,
ui::ConsoleOutputMode::Json => logging_handle.switch_to_json()?,
ui::ConsoleOutputMode::Test => logging_handle.switch_to_test()?,
_ => {}
};

Expand Down Expand Up @@ -291,6 +288,6 @@ use tracing_subscriber::{
Layer,
};

use crate::app::{self, ui, config};
use crate::app::{self, config, ui};

// endregion: IMPORTS
57 changes: 45 additions & 12 deletions paxy/src/app/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ where

emit_welcome_messages();

emit_diagnostic_messages(&config, &console_input);
emit_diagnostic_messages(&config);

emit_test_messages();
emit_test_messages(&config, &console_input);

Ok((console_input, logging_handle.worker_guards))
}
Expand All @@ -40,10 +40,18 @@ fn emit_welcome_messages() {
);
}

fn emit_diagnostic_messages<C>(config: &ConfigTemplate, console_input: &C)
where
C: clap::Parser + fmt::Debug,
{
fn emit_diagnostic_messages(config: &ConfigTemplate) {
tracing::trace!(
"{} {} messages {}...",
console::Emoji("🔍", ""),
"Diagnostic"
.cyan()
.dimmed(),
"begin"
.green()
.dimmed(),
);

tracing::debug!(
"{} The {} is {}... {}",
console::Emoji("⚙️", ""),
Expand Down Expand Up @@ -74,16 +82,21 @@ where
);

tracing::trace!(
"{} {} {:#?}",
console::Emoji("⌨️", ""),
"CLI input arguments:"
.magenta()
"{} {} messages {}...",
console::Emoji("🔍", ""),
"Diagnostic"
.cyan()
.dimmed(),
"end"
.green()
.dimmed(),
console_input.dimmed()
);
}

fn emit_test_messages() {
fn emit_test_messages<C>(config: &ConfigTemplate, console_input: &C)
where
C: clap::Parser + fmt::Debug,
{
tracing::debug!(
target:"TEST", "{}{}{}{}{}{}{}{}",
"███".black(),
Expand Down Expand Up @@ -115,6 +128,26 @@ fn emit_test_messages() {

tracing::info!(target:"JSON", "{} Testing: {}", console::Emoji("🧪", ""), "{\"JSON\": \"Target\"}");
tracing::info!(target:"PLAIN", "{} Testing: Plain Target", console::Emoji("🧪", ""));

tracing::info!(
target:"TEST",
"{} {} {:#?}",
console::Emoji("⌨️", ""),
"CLI input arguments:"
.magenta()
.dimmed(),
console_input.dimmed()
);

tracing::info!(
target:"TEST",
"{} {} {:#?}",
console::Emoji("⌨️", ""),
"Config dump:"
.magenta()
.dimmed(),
config.dimmed()
);
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down

0 comments on commit 9155671

Please sign in to comment.