Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Jun 14, 2024
1 parent 5583d21 commit d38bcc3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions lychee-bin/src/formatters/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ use crate::{
pub(crate) fn init_logging(verbose: &Verbosity, mode: &OutputMode) {
// Set a base level for all modules to `warn`, which is a reasonable default.
// It will be overridden by RUST_LOG if it's set.
let base_level = "warn";
let env = Env::default().filter_or("RUST_LOG", base_level);
let env = Env::default().filter_or("RUST_LOG", "warn");

let mut builder = Builder::from_env(env);

builder
.format_timestamp(None)
.format_module_path(false)
Expand All @@ -28,7 +26,7 @@ pub(crate) fn init_logging(verbose: &Verbosity, mode: &OutputMode) {
let level_filter = verbose.log_level_filter();

// Apply a global filter. This ensures that, by default, other modules don't log at the debug level.
builder.filter_level(LevelFilter::Info); // Set to `Info` or another level as you see fit.
builder.filter_level(LevelFilter::Info);

// Apply more specific filters to your own crates, enabling more verbose logging as per `-vv`.
builder
Expand All @@ -42,9 +40,9 @@ pub(crate) fn init_logging(verbose: &Verbosity, mode: &OutputMode) {
.max()
.unwrap_or(0);

// Customize the log message format if not plain.
// Customize the log message format according to the output mode
if mode.is_plain() {
// Explicitly disable colors for plain output.
// Explicitly disable colors for plain output
builder.format(move |buf, record| writeln!(buf, "[{}] {}", record.level(), record.args()));
} else if mode.is_emoji() {
// Disable padding, keep colors
Expand Down
2 changes: 1 addition & 1 deletion lychee-bin/src/formatters/response/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{ResponseFormatter, MAX_RESPONSE_OUTPUT_WIDTH};

/// A colorized formatter for the response body
///
/// This formatter is used when the terminal supports color and the user
/// This formatter is used if the terminal supports color and the user
/// has not explicitly requested raw, uncolored output.
pub(crate) struct ColorFormatter;

Expand Down
1 change: 1 addition & 0 deletions lychee-bin/src/formatters/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ pub(crate) const MAX_RESPONSE_OUTPUT_WIDTH: usize = 10;
/// It can be implemented for different formatting styles such as
/// colorized output or plaintext.
pub(crate) trait ResponseFormatter: Send + Sync {
/// Format the response body into a human-readable string
fn format_response(&self, body: &ResponseBody) -> String;
}

0 comments on commit d38bcc3

Please sign in to comment.