From e79e0ab27252136ef3b188fa01e3ac6f2fedd010 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 7 Nov 2023 17:12:03 +0800 Subject: [PATCH] [server] Add output formatting to logprintf --- server/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/main.cpp b/server/main.cpp index 67a1f34..a95c39e 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -285,7 +285,28 @@ void logprintf(char* format, ...) puts(output); fflush(stdout); #else + if (pConsole && pConsole->GetBoolVariable("output")) + { + puts(buffer); + } #endif + if (pLogFile) { + if (pConsole) { + if (pConsole->GetBoolVariable("timestamp")) + { + const struct tm *tm; + time_t now; + now = time(NULL); + tm = localtime(&now); + char s[256]; + strftime(s, 256, pConsole->GetStringVariable("logtimeformat"), tm); + fprintf(pLogFile, "%s %s\n", s, buffer); + } + else fprintf(pLogFile, "%s\n", buffer); + } + else fprintf(pLogFile, "%s\n", buffer); + fflush(pLogFile); + } // TODO: logprintf }