Skip to content

Commit

Permalink
fix: [torrust#917] clients output in JSON should not include logging
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jun 26, 2024
1 parent eb9f997 commit 2518c54
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
48 changes: 46 additions & 2 deletions src/console/clients/checker/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,56 @@
//! ```text
//! TORRUST_CHECKER_CONFIG=$(cat "./share/default/config/tracker_checker.json") cargo run --bin tracker_checker
//! ```
//!
//! Another real example to test the Torrust demo tracker:
//!
//! ```text
//! TORRUST_CHECKER_CONFIG='{
//! "udp_trackers": ["144.126.245.19:6969"],
//! "http_trackers": ["https://tracker.torrust-demo.com"],
//! "health_checks": ["https://tracker.torrust-demo.com/api/health_check"]
//! }' cargo run --bin tracker_checker
//! ```
//!
//! The output should be something like the following:
//!
//! ```json
//! {
//! "udp_trackers": [
//! {
//! "url": "144.126.245.19:6969",
//! "status": {
//! "code": "ok",
//! "message": ""
//! }
//! }
//! ],
//! "http_trackers": [
//! {
//! "url": "https://tracker.torrust-demo.com/",
//! "status": {
//! "code": "ok",
//! "message": ""
//! }
//! }
//! ],
//! "health_checks": [
//! {
//! "url": "https://tracker.torrust-demo.com/api/health_check",
//! "status": {
//! "code": "ok",
//! "message": ""
//! }
//! }
//! ]
//! }
//! ```
use std::path::PathBuf;
use std::sync::Arc;

use anyhow::{Context, Result};
use clap::Parser;
use tracing::info;
use tracing::debug;
use tracing::level_filters::LevelFilter;

use super::config::Configuration;
Expand Down Expand Up @@ -59,7 +103,7 @@ pub async fn run() -> Result<Vec<CheckResult>> {

fn tracing_stdout_init(filter: LevelFilter) {
tracing_subscriber::fmt().with_max_level(filter).init();
info!("logging initialized.");
debug!("logging initialized.");
}

fn setup_config(args: Args) -> Result<Configuration> {
Expand Down
4 changes: 2 additions & 2 deletions src/console/clients/udp/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ use anyhow::Context;
use aquatic_udp_protocol::{Port, Response, TransactionId};
use clap::{Parser, Subcommand};
use torrust_tracker_primitives::info_hash::InfoHash as TorrustInfoHash;
use tracing::debug;
use tracing::level_filters::LevelFilter;
use tracing::{debug, info};
use url::Url;

use crate::console::clients::udp::checker;
Expand Down Expand Up @@ -128,7 +128,7 @@ pub async fn run() -> anyhow::Result<()> {

fn tracing_stdout_init(filter: LevelFilter) {
tracing_subscriber::fmt().with_max_level(filter).init();
info!("logging initialized.");
debug!("logging initialized.");
}

async fn handle_announce(tracker_socket_addr: &SocketAddr, info_hash: &TorrustInfoHash) -> anyhow::Result<Response> {
Expand Down

0 comments on commit 2518c54

Please sign in to comment.