GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
mgba_logger.h
Go to the documentation of this file.
1
24#ifndef MGBA_LOGGER_H
25#define MGBA_LOGGER_H
26
27#include <stdbool.h>
28
29typedef enum
30{
31 MGBA_LOG_FATAL,
32 MGBA_LOG_ERROR,
33 MGBA_LOG_WARN,
34 MGBA_LOG_INFO,
35 MGBA_LOG_DEBUG,
36} MgbaLogLevel;
37
44bool mgba_logger_init(void);
45
55void mgba_printf(MgbaLogLevel level, const char* fmt, ...);
56
67void mgba_func_printf(MgbaLogLevel level, const char* func_name, const char* fmt, ...);
68
69// clang-format off
70#ifdef MGBA_LOGGING
71
72#define MGBA_FATAL(...) mgba_printf(MGBA_LOG_FATAL, __VA_ARGS__)
73#define MGBA_ERROR(...) mgba_printf(MGBA_LOG_ERROR, __VA_ARGS__)
74#define MGBA_WARN(...) mgba_printf(MGBA_LOG_WARN, __VA_ARGS__)
75#define MGBA_INFO(...) mgba_printf(MGBA_LOG_INFO, __VA_ARGS__)
76#define MGBA_DEBUG(...) mgba_printf(MGBA_LOG_DEBUG, __VA_ARGS__)
77
78#define MGBA_FUNC_LOG(level, ...) mgba_func_printf(level, __func__, __VA_ARGS__)
79
80#define MGBA_FUNC_FATAL(...) MGBA_FUNC_LOG(MGBA_LOG_FATAL, __VA_ARGS__)
81#define MGBA_FUNC_ERROR(...) MGBA_FUNC_LOG(MGBA_LOG_ERROR, __VA_ARGS__)
82#define MGBA_FUNC_WARN(...) MGBA_FUNC_LOG(MGBA_LOG_WARN, __VA_ARGS__)
83#define MGBA_FUNC_INFO(...) MGBA_FUNC_LOG(MGBA_LOG_INFO, __VA_ARGS__)
84#define MGBA_FUNC_DEBUG(...) MGBA_FUNC_LOG(MGBA_LOG_DEBUG, __VA_ARGS__)
85
86#else
87
88#define MGBA_FATAL(...) ((void)0)
89#define MGBA_ERROR(...) ((void)0)
90#define MGBA_WARN(...) ((void)0)
91#define MGBA_INFO(...) ((void)0)
92#define MGBA_DEBUG(...) ((void)0)
93
94#define MGBA_FUNC_LOG(level, ...) ((void)0)
95
96#define MGBA_FUNC_FATAL(...) ((void)0)
97#define MGBA_FUNC_ERROR(...) ((void)0)
98#define MGBA_FUNC_WARN(...) ((void)0)
99#define MGBA_FUNC_INFO(...) ((void)0)
100#define MGBA_FUNC_DEBUG(...) ((void)0)
101#endif
102// clang-format on
103
104#endif
bool mgba_logger_init(void)
Initialize mgba logger.
Definition mgba_logger.c:69
void mgba_func_printf(MgbaLogLevel level, const char *func_name, const char *fmt,...)
Print to mgba log with a format string and function name.
Definition mgba_logger.c:78
void mgba_printf(MgbaLogLevel level, const char *fmt,...)
Print to mgba log with a format string.
Definition mgba_logger.c:74