# HG changeset patch # User Matti Hamalainen # Date 1352652669 -7200 # Node ID d8184a3c241f1b2d67f4600c0c089b2c536ce890 # Parent 44f67ec5e945fa5cdda4d98897362f42bdafc498 Clean up window logging logic a bit. diff -r 44f67ec5e945 -r d8184a3c241f main.c --- 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))