Skip to content

Commit

Permalink
Merge branch 'fix-stderr-stdout-tty-logging' into 'master'
Browse files Browse the repository at this point in the history
DOR-237 fix no output when stdout == stderr and both are the tty

See merge request machine-learning/dorado!460
  • Loading branch information
iiSeymour committed Jun 30, 2023
2 parents 7e70de7 + a5818b5 commit 3090328
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dorado/utils/log_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/spdlog.h"
#include "utils/cli_utils.h"

#ifndef _WIN32
#include <fcntl.h>
Expand Down Expand Up @@ -47,7 +48,14 @@ bool is_safe_to_log() {
#ifdef _WIN32
return true;
#else
return get_file_path(fileno(stdout)) != get_file_path(fileno(stderr));
if (get_file_path(fileno(stdout)) == get_file_path(fileno(stderr))) {
// if both stdout and stderr are ttys it's safe to log
if (utils::is_fd_tty(stderr)) {
return true;
}
return false;
}
return true;
#endif
}

Expand Down

0 comments on commit 3090328

Please sign in to comment.