Introduce always_log() that also logs on release build, and increase all the log buffers to 8192 bytes.

This commit is contained in:
OBattler
2025-08-09 15:01:08 +02:00
parent c5ecbd62fc
commit 38b1c190fa
2 changed files with 31 additions and 6 deletions

View File

@@ -385,11 +385,35 @@ pclog(UNUSED(const char *fmt), ...)
#endif #endif
} }
/* Log something even in release builds. */
void
always_log(const char *fmt, ...)
{
char temp[LOG_SIZE_BUFFER];
va_list ap;
va_start(ap, fmt);
if (stdlog == NULL) {
if (log_path[0] != '\0') {
stdlog = plat_fopen(log_path, "w");
if (stdlog == NULL)
stdlog = stdout;
} else
stdlog = stdout;
}
vsprintf(temp, fmt, ap);
fprintf(stdlog, "%s", temp);
fflush(stdlog);
va_end(ap);
}
/* Log a fatal error, and display a UI message before exiting. */ /* Log a fatal error, and display a UI message before exiting. */
void void
fatal(const char *fmt, ...) fatal(const char *fmt, ...)
{ {
char temp[1024]; char temp[LOG_SIZE_BUFFER];
va_list ap; va_list ap;
char *sp; char *sp;
@@ -437,7 +461,7 @@ fatal(const char *fmt, ...)
void void
fatal_ex(const char *fmt, va_list ap) fatal_ex(const char *fmt, va_list ap)
{ {
char temp[1024]; char temp[LOG_SIZE_BUFFER];
char *sp; char *sp;
if (stdlog == NULL) { if (stdlog == NULL) {
@@ -480,7 +504,7 @@ fatal_ex(const char *fmt, va_list ap)
void void
warning(const char *fmt, ...) warning(const char *fmt, ...)
{ {
char temp[1024]; char temp[LOG_SIZE_BUFFER];
va_list ap; va_list ap;
char *sp; char *sp;
@@ -516,7 +540,7 @@ warning(const char *fmt, ...)
void void
warning_ex(const char *fmt, va_list ap) warning_ex(const char *fmt, va_list ap)
{ {
char temp[1024]; char temp[LOG_SIZE_BUFFER];
char *sp; char *sp;
if (stdlog == NULL) { if (stdlog == NULL) {
@@ -651,7 +675,7 @@ pc_show_usage(char *s)
ui_msgbox(MBX_ANSI | ((s == NULL) ? MBX_INFO : MBX_WARNING), p); ui_msgbox(MBX_ANSI | ((s == NULL) ? MBX_INFO : MBX_WARNING), p);
#else #else
if (s == NULL) if (s == NULL)
pclog("%s", p); always_log("%s", p);
else else
ui_msgbox(MBX_ANSI | MBX_WARNING, p); ui_msgbox(MBX_ANSI | MBX_WARNING, p);
#endif #endif
@@ -867,7 +891,7 @@ usage:
lang_init = plat_language_code(argv[++c]); lang_init = plat_language_code(argv[++c]);
if (!lang_init) if (!lang_init)
printf("\nWarning: Invalid language code, ignoring --lang parameter.\n\n"); always_log("\nWarning: Invalid language code, ignoring --lang parameter.\n\n");
// The return value of 0 only means that the code is invalid, // The return value of 0 only means that the code is invalid,
// not related to that translation is exists or not for the // not related to that translation is exists or not for the

View File

@@ -201,6 +201,7 @@ extern void warning_ex(const char *fmt, va_list ap);
#endif #endif
extern void pclog_toggle_suppr(void); extern void pclog_toggle_suppr(void);
extern void pclog(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern void pclog(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
extern void always_log(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatal(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern void fatal(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
extern void warning(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern void warning(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
extern void set_screen_size(int x, int y); extern void set_screen_size(int x, int y);