From b94172278cd2a9e303d6eb1fd9f2786869cf3f7f Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 22 Apr 2022 21:59:17 +0200 Subject: [PATCH] Improve logging and add logging section to the README --- Makefile | 5 +++++ README.md | 11 +++++++++++ src/utils/logger.h | 24 +++++++++++++++++------- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 973636c..605106c 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,11 @@ CXXFLAGS += -DDEBUG -g CFLAGS += -DDEBUG -g endif +ifeq ($(DEBUG),VERBOSE) +CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g +CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g +endif + LIBS := -lwums -lwut -lfunctionpatcher #------------------------------------------------------------------------------- diff --git a/README.md b/README.md index 751b279..5140d20 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,17 @@ 2. Requires the [WUMSLoader](https://github.com/wiiu-env/WUMSLoader) in `sd:/wiiu/environments/[ENVIRONMENT]/modules/setup`. 3. Use [libcontentredirection](https://github.com/wiiu-env/libcontentredirection). +## Buildflags + +### Logging +Building via `make` only logs errors (via OSReport). To enable logging via the [LoggingModule](https://github.com/wiiu-env/LoggingModule) set `DEBUG` to `1` or `VERBOSE`. + +`make` Logs errors only (via OSReport). +`make DEBUG=1` Enables information and error logging via [LoggingModule](https://github.com/wiiu-env/LoggingModule). +`make DEBUG=VERBOSE` Enables verbose information and error logging via [LoggingModule](https://github.com/wiiu-env/LoggingModule). + +If the [LoggingModule](https://github.com/wiiu-env/LoggingModule) is not present, it'll fallback to UDP (Port 4405) and [CafeOS](https://github.com/wiiu-env/USBSerialLoggingModule) logging. + ## Building using the Dockerfile It's possible to use a docker image for building. This way you don't need anything installed on your host system. diff --git a/src/utils/logger.h b/src/utils/logger.h index d394030..deb4e7a 100644 --- a/src/utils/logger.h +++ b/src/utils/logger.h @@ -11,8 +11,6 @@ extern "C" { #define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) -// #define VERBOSE_DEBUG - #ifdef DEBUG #ifdef VERBOSE_DEBUG @@ -30,6 +28,7 @@ extern "C" { #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) #define DEBUG_FUNCTION_LINE_VERBOSE_EX(FILENAME, FUNCTION, LINE, FMT, ARGS...) while (0) + #endif #define DEBUG_FUNCTION_LINE(FMT, ARGS...) \ @@ -42,6 +41,16 @@ extern "C" { WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0) +#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) \ + do { \ + WHBLogPrintf("[%23s]%30s@L%04d: ##ERROR## " FMT "\n", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ + } while (0) + +#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) \ + do { \ + WHBLogPrintf("[%23s]%30s@L%04d: ##ERROR## " FMT "\n", FILENAME, FUNCTION, LINE, ##ARGS); \ + } while (0) + #else #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) @@ -52,11 +61,9 @@ extern "C" { #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0) -#endif - -#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) \ - do { \ - OSReport("## ERROR ## [%23s]%30s@L%04d: ##ERROR## " FMT "\n", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ +#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) \ + do { \ + OSReport("[%23s]%30s@L%04d: ##ERROR## " FMT "\n", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ } while (0) #define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) \ @@ -64,6 +71,9 @@ extern "C" { OSReport("[%23s]%30s@L%04d: ##ERROR## " FMT "\n", FILENAME, FUNCTION, LINE, ##ARGS); \ } while (0) +#endif + + void initLogging(); void deinitLogging();