#endif
#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6
-extern void write_log (const TCHAR *, ...);
-extern void write_log (const char *, ...) __attribute__ ((format (printf, 1, 2)));
+extern void write_log(const TCHAR *, ...);
+extern void write_logx(const TCHAR *, ...);
+extern void write_log(const char *, ...) __attribute__ ((format (printf, 1, 2)));
#else
-extern void write_log (const TCHAR *, ...);
-extern void write_log (const char *, ...);
+extern void write_log(const TCHAR *, ...);
+extern void write_logx(const TCHAR *, ...);
+extern void write_log(const char *, ...);
#endif
extern void write_dlog (const TCHAR *, ...);
extern int read_log(void);
if (log_sercon) {
serial_period_hsyncs = 1;
seriallog = 1;
+ write_logx(_T("\n"));
}
serial_period_hsync_counter = 0;
if (seriallog) {
gotlogwrite = true;
- write_log(_T("%c"), docharlog(serdatshift_masked));
+ write_logx(_T("%c"), docharlog(serdatshift_masked));
}
if (serper == 372) {
static int debugger_type = -1;
extern BOOL debuggerinitializing;
extern int lof_store;
+extern int seriallog;
static int console_input_linemode = -1;
int always_flush_log = 1;
va_end (parms);
}
+void write_logx(const TCHAR *format, ...)
+{
+ int count;
+ TCHAR buffer[WRITE_LOG_BUF_SIZE];
+ int bufsize = WRITE_LOG_BUF_SIZE;
+ TCHAR *bufp;
+ va_list parms;
+
+ if (!cs_init)
+ return;
+
+ EnterCriticalSection (&cs);
+ va_start (parms, format);
+ bufp = buffer;
+ for (;;) {
+ count = _vsntprintf (bufp, bufsize - 1, format, parms);
+ if (count < 0) {
+ bufsize *= 10;
+ if (bufp != buffer)
+ xfree (bufp);
+ bufp = xmalloc (TCHAR, bufsize);
+ continue;
+ }
+ break;
+ }
+ bufp[bufsize - 1] = 0;
+ if (1) {
+ writeconsole (bufp);
+ }
+ if (debugfile) {
+ _ftprintf (debugfile, _T("%s"), bufp);
+ }
+ lfdetected = 0;
+ if (_tcslen (bufp) > 0 && bufp[_tcslen (bufp) - 1] == '\n')
+ lfdetected = 1;
+ va_end (parms);
+ if (bufp != buffer)
+ xfree (bufp);
+ LeaveCriticalSection (&cs);
+}
+
void write_log (const TCHAR *format, ...)
{
int count;
TCHAR *bufp;
va_list parms;
+ if (!SHOW_CONSOLE && !console_logging && !debugfile)
+ return;
+
if (!cs_init)
return;