Skip to content

Commit 87f968b

Browse files
committed
--quiet and --log now redirect messages away from stderr
Some computation environments do not tolerate communication on stderr (except for errors of course). Providing a way to keep that channel clean is important.
1 parent acf78c1 commit 87f968b

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/fastqjoin.cc

+29-3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,33 @@ auto join_fileopenw(char * filename) -> std::FILE *
8282
}
8383

8484

85+
auto stats_message(std::FILE * output_stream,
86+
uint64_t const total) -> void {
87+
static_cast<void>(std::fprintf(output_stream,
88+
"%" PRIu64 " pairs joined\n",
89+
total));
90+
}
91+
92+
93+
auto output_stats_message(struct Parameters const & parameters,
94+
uint64_t const total,
95+
char const * log_filename) -> void {
96+
if (log_filename == nullptr) {
97+
return;
98+
}
99+
stats_message(parameters.fp_log, total);
100+
}
101+
102+
103+
auto output_stats_message(struct Parameters const & parameters,
104+
uint64_t const total) -> void {
105+
if (parameters.opt_quiet) {
106+
return;
107+
}
108+
stats_message(stderr, total);
109+
}
110+
111+
85112
auto fastq_join(struct Parameters const & parameters) -> void
86113
{
87114
std::FILE * fp_fastqout = nullptr;
@@ -227,9 +254,8 @@ auto fastq_join(struct Parameters const & parameters) -> void
227254
fatal("More reverse reads than forward reads");
228255
}
229256

230-
std::fprintf(stderr,
231-
"%" PRIu64 " pairs joined\n",
232-
total);
257+
output_stats_message(parameters, total);
258+
output_stats_message(parameters, total, parameters.opt_log);
233259

234260
/* clean up */
235261

0 commit comments

Comments
 (0)