Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: clients output in JSON should not include logging #919

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading