Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit f2f19b2

Browse files
bors[bot]Tobin C. Hardingbonomat
authored
Merge #1765
1765: 1586 stderr r=bonomat a=tcharding Print all diagnostics and log messages to stderr instead of stdout. With this applied the only output that goes to stdout is the output from `cnd --dump-config`. Verify with: `target/debug/cnd 2> /tmp/cnd.stderr`. Resolves: #1586 Co-authored-by: Tobin C. Harding <tobin.harding@coblox.tech> Co-authored-by: Philipp Hoenisch <philipp@hoenisch.at>
2 parents a53ed44 + 98b8021 commit f2f19b2

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
- Write all diagnostics and log messages to stderr.
89

910
## [0.5.0] - 2019-12-06
1011

cnd/src/logging/initialize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use fern::{Dispatch, FormatCallback};
22
use log::{LevelFilter, Record};
3-
use std::{fmt::Arguments, io::stdout};
3+
use std::{fmt::Arguments, io::stderr};
44

55
pub fn initialize(
66
base_log_level: LevelFilter,
77
structured: bool,
88
) -> Result<(), log::SetLoggerError> {
99
#![allow(clippy::print_stdout)] // We cannot use `log` before we have the config file
10-
println!("Initializing logging with base level {}", base_log_level);
10+
eprintln!("Initializing logging with base level {}", base_log_level);
1111

12-
let (max_level, log) = create_logger(base_log_level, structured, stdout());
12+
let (max_level, log) = create_logger(base_log_level, structured, stderr());
1313

1414
log::set_boxed_logger(log)?;
1515
log::set_max_level(max_level);

cnd/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn spawn_warp_instance<S: Network>(
145145
fn read_config(options: &Options) -> anyhow::Result<config::File> {
146146
// if the user specifies a config path, use it
147147
if let Some(path) = &options.config_file {
148-
println!("Using config file {}", path.display());
148+
eprintln!("Using config file {}", path.display());
149149

150150
return config::File::read(&path)
151151
.with_context(|| format!("failed to read config file {}", path.display()));
@@ -158,7 +158,7 @@ fn read_config(options: &Options) -> anyhow::Result<config::File> {
158158
return Ok(config::File::default());
159159
}
160160

161-
println!(
161+
eprintln!(
162162
"Using config file at default path: {}",
163163
default_path.display()
164164
);

0 commit comments

Comments
 (0)