From dd066519f6266d562e8575bdc0a411590b573aef Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 19 Feb 2013 15:05:14 +0200 Subject: [PATCH] mp_msg: print messages to stdout, statusline to stderr Previously, mp_msg() printed text to either stderr or stdout depending on verbosity level (errors/warnings to stderr, rest to stdout). This split had no significant benefits that I know of, and made capturing log output harder as you needed to capture both stdout and stderr. Print all log output to stdout, statusline to stderr. Treat other updated terminal output the same as statusline. --- mp_msg.c | 10 +++++----- mplayer.c | 8 ++++---- stream/cache2.c | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/mp_msg.c b/mp_msg.c index 7b97d286e4..eea65671da 100644 --- a/mp_msg.c +++ b/mp_msg.c @@ -244,7 +244,7 @@ static void print_msg_module(FILE* stream, int mod) void mp_msg_va(int mod, int lev, const char *format, va_list va) { char tmp[MSGSIZE_MAX]; - FILE *stream = lev <= MSGL_WARN ? stderr : stdout; + FILE *stream = mod == MSGT_STATUSLINE ? stderr : stdout; static int header = 1; // indicates if last line printed was a status line static int statusline; @@ -298,9 +298,9 @@ void mp_msg_va(int mod, int lev, const char *format, va_list va) /* A status line is normally intended to be overwritten by the next * status line, and does not end with a '\n'. If we're printing a normal * line instead after the status one print '\n' to change line. */ - if (statusline && lev != MSGL_STATUS) - fprintf(stream, "\n"); - statusline = lev == MSGL_STATUS; + if (statusline && mod != MSGT_STATUSLINE) + fprintf(stderr, "\n"); + statusline = mod == MSGT_STATUSLINE; if (header) print_msg_module(stream, mod); @@ -314,7 +314,7 @@ void mp_msg_va(int mod, int lev, const char *format, va_list va) if (mp_msg_color) { #ifdef _WIN32 - HANDLE *wstream = lev <= MSGL_WARN ? hSTDERR : hSTDOUT; + HANDLE *wstream = stream == stderr ? hSTDERR : hSTDOUT; SetConsoleTextAttribute(wstream, stdoutAttrs); #else fprintf(stream, "\033[0m"); diff --git a/mplayer.c b/mplayer.c index 7504925f6d..dab8535235 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1653,7 +1653,7 @@ static void update_osd_msg(struct MPContext *mpctx) if (mpctx->sh_video) vo_osd_changed(OSDTYPE_OSD); else if (opts->term_osd) - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s%s\n", opts->term_osd_esc, + mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s%s\n", opts->term_osd_esc, msg->msg); } return; @@ -1734,7 +1734,7 @@ static void update_osd_msg(struct MPContext *mpctx) // Clear the term osd line if (opts->term_osd && osd->osd_text[0]) { osd->osd_text[0] = 0; - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s\n", opts->term_osd_esc); + mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\n", opts->term_osd_esc); } } @@ -2928,8 +2928,8 @@ static void update_pause_message(struct MPContext *mpctx) update_osd_msg(mpctx); } else { if (mpctx->status_printed) - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "\n"); - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s\r", msg); + mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "\n"); + mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\r", msg); } mpctx->paused_cache_fill = cache_fill; diff --git a/stream/cache2.c b/stream/cache2.c index 1f948e00ed..ab87426a58 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -477,7 +477,7 @@ int stream_enable_cache(stream_t *stream, int size, int min, int seek_limit) mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %"PRId64" [%"PRId64"] %"PRId64" pre:%d eof:%d \n", (int64_t)s->min_filepos,(int64_t)s->read_filepos,(int64_t)s->max_filepos,min,s->eof); while(s->read_fileposmin_filepos || s->max_filepos-s->read_fileposmax_filepos-s->read_filepos)/(float)(s->buffer_size), (int64_t)s->max_filepos-s->read_filepos ); @@ -487,7 +487,6 @@ int stream_enable_cache(stream_t *stream, int size, int min, int seek_limit) goto err_out; } } - mp_msg(MSGT_CACHE,MSGL_STATUS,"\n"); stream->cached = true; return 1; // parent exits -- 2.11.4.GIT