mirror of
https://github.com/wiiu-env/CustomRPXLoader.git
synced 2024-11-22 09:59:17 +01:00
Move logging into a separate file
This commit is contained in:
parent
a9616036f9
commit
4e29e33931
2
Makefile
2
Makefile
@ -49,7 +49,7 @@ LDFLAGS := -nostartfiles -Wl,--gc-sections,--allow-multiple-definition
|
|||||||
|
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
CXXFLAGS += -DDEBUG -g
|
CXXFLAGS += -DDEBUG -g
|
||||||
CCFLAGS += -DDEBUG -g
|
CFLAGS += -DDEBUG -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
23
src/main.cpp
23
src/main.cpp
@ -30,10 +30,6 @@
|
|||||||
#include "module/ModuleDataFactory.h"
|
#include "module/ModuleDataFactory.h"
|
||||||
#include "common/module_defines.h"
|
#include "common/module_defines.h"
|
||||||
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include <whb/log_udp.h>
|
|
||||||
#include <whb/log_cafe.h>
|
|
||||||
#include <whb/log_module.h>
|
|
||||||
#include <utils/StringTools.h>
|
#include <utils/StringTools.h>
|
||||||
|
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
@ -71,12 +67,6 @@ bool CheckRunning() {
|
|||||||
extern "C" void __init_wut();
|
extern "C" void __init_wut();
|
||||||
extern "C" void __fini_wut();
|
extern "C" void __fini_wut();
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
bool module_log = false;
|
|
||||||
bool udp_log = false;
|
|
||||||
bool cafe_log = false;
|
|
||||||
#endif // DEBUG
|
|
||||||
|
|
||||||
extern "C" int _start(int argc, char **argv) __attribute__ ((section (".start_code")));
|
extern "C" int _start(int argc, char **argv) __attribute__ ((section (".start_code")));
|
||||||
extern "C" int _start(int argc, char **argv) {
|
extern "C" int _start(int argc, char **argv) {
|
||||||
doKernelSetup();
|
doKernelSetup();
|
||||||
@ -90,21 +80,12 @@ extern "C" int _start(int argc, char **argv) {
|
|||||||
auto heap = (MEMExpHeap *) mem2_heap_handle;
|
auto heap = (MEMExpHeap *) mem2_heap_handle;
|
||||||
MEMExpHeapBlock *memory_start = heap->usedList.tail;
|
MEMExpHeapBlock *memory_start = heap->usedList.tail;
|
||||||
|
|
||||||
#ifdef DEBUG
|
initLogging();
|
||||||
if (!(module_log = WHBLogModuleInit())) {
|
|
||||||
cafe_log = WHBLogCafeInit();
|
|
||||||
udp_log = WHBLogUdpInit();
|
|
||||||
}
|
|
||||||
#endif // DEBUG
|
|
||||||
DEBUG_FUNCTION_LINE("Hello from CustomRPXloader");
|
DEBUG_FUNCTION_LINE("Hello from CustomRPXloader");
|
||||||
|
|
||||||
uint32_t entrypoint = do_start(argc, argv);
|
uint32_t entrypoint = do_start(argc, argv);
|
||||||
|
|
||||||
#ifdef DEBUG
|
deinitLogging();
|
||||||
if (module_log) { WHBLogModuleDeinit(); }
|
|
||||||
if (udp_log) { WHBLogUdpDeinit(); }
|
|
||||||
if (cafe_log) { WHBLogCafeDeinit(); }
|
|
||||||
#endif // DEBUG
|
|
||||||
|
|
||||||
// free leaked memory
|
// free leaked memory
|
||||||
if (memory_start) {
|
if (memory_start) {
|
||||||
|
36
src/utils/logger.c
Normal file
36
src/utils/logger.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifdef DEBUG
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <whb/log_udp.h>
|
||||||
|
#include <whb/log_cafe.h>
|
||||||
|
#include <whb/log_module.h>
|
||||||
|
|
||||||
|
uint32_t moduleLogInit = false;
|
||||||
|
uint32_t cafeLogInit = false;
|
||||||
|
uint32_t udpLogInit = false;
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
|
void initLogging() {
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||||
|
cafeLogInit = WHBLogCafeInit();
|
||||||
|
udpLogInit = WHBLogUdpInit();
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
||||||
|
|
||||||
|
void deinitLogging() {
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (moduleLogInit) {
|
||||||
|
WHBLogModuleDeinit();
|
||||||
|
moduleLogInit = false;
|
||||||
|
}
|
||||||
|
if (cafeLogInit) {
|
||||||
|
WHBLogCafeDeinit();
|
||||||
|
cafeLogInit = false;
|
||||||
|
}
|
||||||
|
if (udpLogInit) {
|
||||||
|
WHBLogUdpDeinit();
|
||||||
|
udpLogInit = false;
|
||||||
|
}
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
@ -12,6 +12,8 @@ extern "C" {
|
|||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -22,12 +24,18 @@ extern "C" {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void initLogging();
|
||||||
|
|
||||||
|
void deinitLogging();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user