diff --git a/examples/cli/main.cpp b/examples/cli/main.cpp index 25ed7664a..dfac337ca 100644 --- a/examples/cli/main.cpp +++ b/examples/cli/main.cpp @@ -460,8 +460,8 @@ void sd_log_cb(enum sd_log_level_t level, const char* log, void* data) { return; } if (level <= SD_LOG_INFO) { - fputs(log, stdout); - fflush(stdout); + fputs(log, stderr); + fflush(stderr); } else { fputs(log, stderr); fflush(stderr); @@ -597,7 +597,7 @@ int main(int argc, const char* argv[]) { std::string final_image_path = i > 0 ? dummy_name + "_" + std::to_string(i + 1) + ".png" : dummy_name + ".png"; stbi_write_png(final_image_path.c_str(), results[i].width, results[i].height, results[i].channel, results[i].data, 0, get_image_params(params, params.seed + i).c_str()); - printf("save result image to '%s'\n", final_image_path.c_str()); + fprintf(stderr, "save result image to '%s'\n", final_image_path.c_str()); free(results[i].data); results[i].data = NULL; } diff --git a/util.cpp b/util.cpp index 4057d13d0..7f902b1b0 100644 --- a/util.cpp +++ b/util.cpp @@ -183,13 +183,15 @@ void pretty_progress(int step, int steps, float time) { } } progress += "|"; - printf(time > 1.0f ? "\r%s %i/%i - %.2fs/it" : "\r%s %i/%i - %.2fit/s", + fprintf(stderr, time > 1.0f ? "\r%s %i/%i - %.2fs/it" : "\r%s %i/%i - %.2fit/s", progress.c_str(), step, steps, time > 1.0f || time == 0 ? time : (1.0f / time)); - fflush(stdout); // for linux + fflush(stderr); // for linux if (step == steps) { - printf("\n"); + fprintf(stderr, "\n"); } + fprintf(stdout, "{'step' : '%i', 'steps': '%i', 'time': '%.2f'}\n", step, steps, time); + fflush(stdout); // for linux } static sd_log_cb_t sd_log_cb = NULL;