Mercurial > hg > nnchat
changeset 542:d8184a3c241f
Clean up window logging logic a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 11 Nov 2012 18:51:09 +0200 |
parents | 44f67ec5e945 |
children | 96d636c37976 |
files | main.c |
diffstat | 1 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Sun Nov 11 18:32:42 2012 +0200 +++ b/main.c Sun Nov 11 18:51:09 2012 +0200 @@ -230,6 +230,16 @@ return 0; } +void printMsgFile(nn_window_t *win, int flags, const char *stamp, const char *msg) +{ + if (win != NULL && win->logFile != NULL) + { + if (flags & LOG_STAMP) printFile(win->logFile, stamp); + printFile(win->logFile, msg); + fflush(win->logFile); + } +} + void printMsgV(nn_window_t *win, int flags, const char *fmt, va_list ap) { char tmpStr[128], *buf; @@ -241,11 +251,13 @@ buf = th_strdup_vprintf(fmt, ap); - if (win != NULL && win->logFile && (flags & LOG_FILE)) + if (flags & LOG_FILE) { - if (flags & LOG_STAMP) printFile(win->logFile, tmpStr); - printFile(win->logFile, buf); - fflush(win->logFile); + nn_window_t *mwin = nnwin_main_window(); + if (win != mwin) + printMsgFile(win, flags, tmpStr, buf); + + printMsgFile(mwin, flags, tmpStr, buf); } if (!optDaemon && (flags & LOG_WINDOW))