comparison main.c @ 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 e30fa8592a48
comparison
equal deleted inserted replaced
541:44f67ec5e945 542:d8184a3c241f
228 } 228 }
229 229
230 return 0; 230 return 0;
231 } 231 }
232 232
233 void printMsgFile(nn_window_t *win, int flags, const char *stamp, const char *msg)
234 {
235 if (win != NULL && win->logFile != NULL)
236 {
237 if (flags & LOG_STAMP) printFile(win->logFile, stamp);
238 printFile(win->logFile, msg);
239 fflush(win->logFile);
240 }
241 }
242
233 void printMsgV(nn_window_t *win, int flags, const char *fmt, va_list ap) 243 void printMsgV(nn_window_t *win, int flags, const char *fmt, va_list ap)
234 { 244 {
235 char tmpStr[128], *buf; 245 char tmpStr[128], *buf;
236 246
237 if (flags & LOG_STAMP) 247 if (flags & LOG_STAMP)
239 str_get_timestamp(tmpStr, sizeof(tmpStr), "½17½[½11½%H:%M:%S½17½]½0½ "); 249 str_get_timestamp(tmpStr, sizeof(tmpStr), "½17½[½11½%H:%M:%S½17½]½0½ ");
240 } 250 }
241 251
242 buf = th_strdup_vprintf(fmt, ap); 252 buf = th_strdup_vprintf(fmt, ap);
243 253
244 if (win != NULL && win->logFile && (flags & LOG_FILE)) 254 if (flags & LOG_FILE)
245 { 255 {
246 if (flags & LOG_STAMP) printFile(win->logFile, tmpStr); 256 nn_window_t *mwin = nnwin_main_window();
247 printFile(win->logFile, buf); 257 if (win != mwin)
248 fflush(win->logFile); 258 printMsgFile(win, flags, tmpStr, buf);
259
260 printMsgFile(mwin, flags, tmpStr, buf);
249 } 261 }
250 262
251 if (!optDaemon && (flags & LOG_WINDOW)) 263 if (!optDaemon && (flags & LOG_WINDOW))
252 { 264 {
253 nn_window_t *tmp = (win != NULL) ? win : nnwin_main_window(); 265 nn_window_t *tmp = (win != NULL) ? win : nnwin_main_window();