mirror of
https://github.com/devkitPro/wut.git
synced 2026-04-21 08:47:20 -05:00
libwhb: Add option to log to the LoggingModule
This commit is contained in:
parent
563b9d6c89
commit
ce2cd4e843
24
libraries/libwhb/include/whb/log_module.h
Normal file
24
libraries/libwhb/include/whb/log_module.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#include <wut.h>
|
||||
|
||||
/**
|
||||
* \defgroup whb_log_module Log using the LoggingModule.
|
||||
* \ingroup whb
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
BOOL
|
||||
WHBLogModuleInit();
|
||||
|
||||
BOOL
|
||||
WHBLogModuleDeinit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
37
libraries/libwhb/src/log_module.c
Normal file
37
libraries/libwhb/src/log_module.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include <coreinit/dynload.h>
|
||||
#include <coreinit/debug.h>
|
||||
#include <whb/log.h>
|
||||
#include <string.h>
|
||||
|
||||
static OSDynLoad_Module sModuleHandle = NULL;
|
||||
static void (*sWUMSLogWrite)(const char *, size_t) = NULL;
|
||||
|
||||
static void
|
||||
moduleLogHandler(const char *msg)
|
||||
{
|
||||
if(sWUMSLogWrite != NULL) {
|
||||
sWUMSLogWrite(msg, strlen(msg));
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogModuleInit()
|
||||
{
|
||||
if (OSDynLoad_Acquire("homebrew_logging", &sModuleHandle) != OS_DYNLOAD_OK) {
|
||||
OSReport("WHBLogModuleInit: OSDynLoad_Acquire failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, FALSE, "WUMSLogWrite", (void**) &sWUMSLogWrite) != OS_DYNLOAD_OK) {
|
||||
OSReport("WHBLogModuleInit: OSDynLoad_FindExport failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return WHBAddLogHandler(moduleLogHandler);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogModuleDeinit()
|
||||
{
|
||||
return WHBRemoveLogHandler(moduleLogHandler);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user