summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-10-11 14:52:34 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-10-11 14:52:34 +0300
commit517378721855280d2e23d25d7529e6b9cbae9136 (patch)
treec8e76d10eadc2e8e2ccc11809b1e63b1fffcecad /src/print.c
parenta6c4103df550ec7c1d99af6a5573c2e3f946b408 (diff)
downloadapk-tools-517378721855280d2e23d25d7529e6b9cbae9136.tar.gz
apk-tools-517378721855280d2e23d25d7529e6b9cbae9136.tar.bz2
apk-tools-517378721855280d2e23d25d7529e6b9cbae9136.tar.xz
apk-tools-517378721855280d2e23d25d7529e6b9cbae9136.zip
print: use stdout instead of stderr for logging and progress
stdout is the proper place for it. this also fixes the progress bar in musl, which seems to not support using line buffering for stderr.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/print.c b/src/print.c
index 6d00064..aafe2ef 100644
--- a/src/print.c
+++ b/src/print.c
@@ -35,7 +35,7 @@ int apk_get_screen_width(void)
if (apk_screen_width == 0) {
apk_screen_width = 50;
- if (ioctl(STDERR_FILENO, TIOCGWINSZ, &w) == 0 &&
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == 0 &&
w.ws_col > 50)
apk_screen_width = w.ws_col;
}
@@ -77,14 +77,14 @@ void apk_print_progress(size_t done, size_t total)
last_percent = percent;
apk_progress_force = 0;
- fprintf(stderr, "\e7%3i%% [", percent);
+ fprintf(stdout, "\e7%3i%% [", percent);
for (i = 0; i < bar; i++)
- fputc('#', stderr);
+ fputc('#', stdout);
for (; i < bar_width; i++)
- fputc(' ', stderr);
- fputc(']', stderr);
- fflush(stderr);
- fputs("\e8\e[0K", stderr);
+ fputc(' ', stdout);
+ fputc(']', stdout);
+ fflush(stdout);
+ fputs("\e8\e[0K", stdout);
}
int apk_print_indented(struct apk_indent *i, apk_blob_t blob)
@@ -144,11 +144,11 @@ void apk_log(const char *prefix, const char *format, ...)
va_list va;
if (prefix != NULL)
- fprintf(stderr, "%s", prefix);
+ fprintf(stdout, "%s", prefix);
va_start(va, format);
- vfprintf(stderr, format, va);
+ vfprintf(stdout, format, va);
va_end(va);
- fprintf(stderr, "\n");
+ fprintf(stdout, "\n");
apk_progress_force = 1;
}