From: Toni Wilen Date: Sat, 14 Jul 2018 18:24:44 +0000 (+0300) Subject: Serial log datestamp option. X-Git-Tag: 4010~5 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=cc5bfbcd107d3fd76d8d28f2aedb0abe27db0b67;p=francis%2Fwinuae.git Serial log datestamp option. --- diff --git a/include/sysdeps.h b/include/sysdeps.h index 8a6e6537..756f2637 100644 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -469,6 +469,7 @@ extern int gui_message_multibutton (int flags, const TCHAR *format,...); extern void logging_init (void); extern FILE *log_open (const TCHAR *name, int append, int bootlog, TCHAR*); extern void log_close (FILE *f); +extern TCHAR *write_log_get_ts(void); extern bool use_long_double; diff --git a/od-win32/serial_win32.cpp b/od-win32/serial_win32.cpp index 1e581dda..20822e99 100644 --- a/od-win32/serial_win32.cpp +++ b/od-win32/serial_win32.cpp @@ -178,6 +178,7 @@ static int serdatr_last_got; int serdev; int seriallog = 0, log_sercon = 0; int serial_enet; +static bool seriallog_lf; extern int consoleopen; void serial_open (void); @@ -227,7 +228,8 @@ void SERPER (uae_u16 w) #endif if (log_sercon) { serial_period_hsyncs = 1; - seriallog = 1; + seriallog = log_sercon; + seriallog_lf = true; write_logx(_T("\n")); } @@ -481,7 +483,16 @@ static void serdatcopy(void) if (seriallog > 0 || (consoleopen && seriallog < 0)) { gotlogwrite = true; - write_logx(_T("%c"), docharlog(serdatshift_masked)); + if (seriallog_lf && seriallog > 1) { + TCHAR *ts = write_log_get_ts(); + if (ts) + write_logx(_T("%s:"), ts); + seriallog_lf = false; + } + TCHAR ch = docharlog(serdatshift_masked); + write_logx(_T("%c"), ch); + if (ch == 10) + seriallog_lf = true; } if (serper == 372) { diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 79b302a5..50b3cb99 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -6176,6 +6176,10 @@ static int parseargs(const TCHAR *argx, const TCHAR *np, const TCHAR *np2) log_sercon = 1; return 1; } + if (!_tcscmp(arg, _T("serlog2"))) { + log_sercon = 2; + return 1; + } if (!_tcscmp(arg, _T("a2065log"))) { log_a2065 = 1; return 1; diff --git a/od-win32/writelog.cpp b/od-win32/writelog.cpp index 4cb003d6..64a82c73 100644 --- a/od-win32/writelog.cpp +++ b/od-win32/writelog.cpp @@ -482,7 +482,7 @@ void console_flush (void) static int lfdetected = 1; -static TCHAR *writets (void) +TCHAR *write_log_get_ts(void) { struct tm *t; struct _timeb tb; @@ -657,7 +657,7 @@ void write_log (const TCHAR *format, ...) bufp[bufsize - 1] = 0; if (!_tcsncmp (bufp, _T("write "), 6)) bufsize--; - ts = writets (); + ts = write_log_get_ts(); if (bufp[0] == '*') count++; if (SHOW_CONSOLE || console_logging) {