diff --git a/src/caldir.c b/src/caldir.c index bc2361647..555218fed 100644 --- a/src/caldir.c +++ b/src/caldir.c @@ -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" @@ -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); diff --git a/src/cc.c b/src/cc.c index d75d623d1..85f3102e2 100644 --- a/src/cc.c +++ b/src/cc.c @@ -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; } diff --git a/src/ccapply.c b/src/ccapply.c index a3aeb2e64..b20972a3a 100644 --- a/src/ccapply.c +++ b/src/ccapply.c @@ -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; } diff --git a/src/ecalib.c b/src/ecalib.c index 3d695ef7d..a30251c4e 100644 --- a/src/ecalib.c +++ b/src/ecalib.c @@ -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); diff --git a/src/ecaltwo.c b/src/ecaltwo.c index fe43af39a..64c3b2a32 100644 --- a/src/ecaltwo.c +++ b/src/ecaltwo.c @@ -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); diff --git a/src/estdelay.c b/src/estdelay.c index 41633c39e..a448a253a 100644 --- a/src/estdelay.c +++ b/src/estdelay.c @@ -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]; @@ -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); diff --git a/src/misc/debug.c b/src/misc/debug.c index 2e488ee69..d89953281 100644 --- a/src/misc/debug.c +++ b/src/misc/debug.c @@ -152,6 +152,23 @@ 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' }; @@ -159,8 +176,11 @@ void debug_vprintf(int level, const char* fmt, va_list ap) 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); diff --git a/src/misc/io.c b/src/misc/io.c index 82ac74969..953a30173 100644 --- a/src/misc/io.c +++ b/src/misc/io.c @@ -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 { diff --git a/src/nufft.c b/src/nufft.c index 03cb015c2..554804d85 100644 --- a/src/nufft.c +++ b/src/nufft.c @@ -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; }