Skip to content

Commit

Permalink
remove msgs interfering with streams on stdout + pipe debugging option
Browse files Browse the repository at this point in the history
  • Loading branch information
mblum94 authored and uecker committed Jul 6, 2024
1 parent 543578f commit 1416294
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/caldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "misc/misc.h"
#include "misc/mri.h"
#include "misc/opts.h"
#include "misc/debug.h"

#include "num/multind.h"
#include "num/fft.h"

#include "calib/direct.h"

Expand Down Expand Up @@ -64,11 +64,11 @@ int main_caldir(int argc, char* argv[argc])
long caldims[DIMS];
complex float* cal_data = extract_calib(caldims, calsize, dims, in_data, false);

printf("Calibration region %ldx%ldx%ld\n", caldims[0], caldims[1], caldims[2]);
debug_printf(DP_DEBUG1, "Calibration region %ldx%ldx%ld\n", caldims[0], caldims[1], caldims[2]);

direct_calib(dims, out_data, caldims, cal_data);

printf("Done.\n");
debug_printf(DP_DEBUG1, "Done.\n");

md_free(cal_data);

Expand Down
2 changes: 1 addition & 1 deletion src/cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int main_cc(int argc, char* argv[argc])
unmap_cfl(DIMS, out_dims, out_data);
}

printf("Done.\n");
debug_printf(DP_DEBUG1, "Done.\n");

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ccapply.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main_ccapply(int argc, char* argv[argc])
unmap_cfl(DIMS, in_dims, in_data);
unmap_cfl(DIMS, out_dims, out_data);

printf("Done.\n");
debug_printf(DP_DEBUG1, "Done.\n");

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ecalib.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ int main_ecalib(int argc, char* argv[argc])
for (int i = 0; i < K; i++)
printf("SVALS %d %f\n", i, svals[i]);

printf("Done.\n");
debug_printf(DP_DEBUG1, "Done.\n");

unmap_cfl(N, ksp_dims, in_data);

Expand Down
2 changes: 1 addition & 1 deletion src/ecaltwo.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int main_ecaltwo(int argc, char* argv[argc])

fixphase(DIMS, out_dims, COIL_DIM, out_data, out_data);

debug_printf(DP_INFO, "Done.\n");
debug_printf(DP_DEBUG1, "Done.\n");

unmap_cfl(DIMS, in_dims, in_data);
unmap_cfl(DIMS, out_dims, out_data);
Expand Down
5 changes: 3 additions & 2 deletions src/estdelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ int main_estdelay(int argc, char* argv[argc])
qf[1] -= dc_shift / scale;


bart_printf("%f:%f:%f\n", qf[0], qf[1], qf[2]);

if (NULL != qf_file) {

long qf_dims[DIMS];
Expand All @@ -173,6 +171,9 @@ int main_estdelay(int argc, char* argv[argc])
oqf[i] = qf[i];

unmap_cfl(DIMS, qf_dims, oqf);
} else {

bart_printf("%f:%f:%f\n", qf[0], qf[1], qf[2]);
}

unmap_cfl(DIMS, full_dims, full_in);
Expand Down
22 changes: 21 additions & 1 deletion src/misc/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,35 @@ void debug_vprintf(int level, const char* fmt, va_list ap)

} else {

char* str = getenv("BART_DEBUG_STREAM");
const char* cmd = NULL;

if (NULL != str) {

errno = 0;
long r = strtol(str, NULL, 10);

if ((errno == 0) && (1 <= r)) {

ofp = stderr;
cmd = ptr_printf(" (%s)", command_line ?: "bart wrapper");
}

errno = 0;
}

if (level < DP_INFO) {

char rank[16] = { '\0' };

if (1 < mpi_get_num_procs())
sprintf(rank, " [Rank %d]", mpi_get_rank());

fprintf(ofp, "%s%s%s: ", (level < DP_INFO ? RED : ""), get_level_str(level), rank);
fprintf(ofp, "%s%s%s%s: ", (level < DP_INFO ? RED : ""), get_level_str(level), rank, cmd?:"");
}

if (NULL != cmd)
xfree(cmd);
}

vfprintf(ofp, fmt, ap);
Expand Down
2 changes: 1 addition & 1 deletion src/misc/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static void io_register(const char* name, bool output, bool input, bool open)

if (iop->open) {

if (output || iop->output)
if ((output || iop->output) && (0 != strcmp(name, "-")))
debug_printf(DP_WARN, "Overwriting file: %s\n", name);

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/nufft.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int main_nufft(int argc, char* argv[argc])
if (NULL != pattern)
unmap_cfl(DIMS, pattern_dims, pattern);

debug_printf(DP_INFO, "Done.\n");
debug_printf(DP_DEBUG1, "Done.\n");

return 0;
}
Expand Down

0 comments on commit 1416294

Please sign in to comment.