Update error and debug logging methods
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
|
||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
log.c
|
||||
)
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "log/log.h"
|
||||
|
||||
void logDebug(const char_t *message, ...) {
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
|
||||
// print to stdout
|
||||
va_list copy;
|
||||
va_copy(copy, args);
|
||||
vprintf(message, copy);
|
||||
va_end(copy);
|
||||
|
||||
// print to file
|
||||
FILE *file = fopen("ms0:/PSP/GAME/Dusk/debug.log", "a");
|
||||
if (file) {
|
||||
va_copy(copy, args);
|
||||
vfprintf(file, message, copy);
|
||||
va_end(copy);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void logError(const char_t *message, ...) {
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
|
||||
// print to stderr
|
||||
va_list copy;
|
||||
va_copy(copy, args);
|
||||
vfprintf(stderr, message, copy);
|
||||
va_end(copy);
|
||||
|
||||
// print to file
|
||||
FILE *file = fopen("ms0:/PSP/GAME/Dusk/error.log", "a");
|
||||
if (file) {
|
||||
va_copy(copy, args);
|
||||
vfprintf(file, message, copy);
|
||||
va_end(copy);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
Reference in New Issue
Block a user