forked from MokhaLeee/fe8u-cskillsys-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug-kit.h
69 lines (62 loc) · 3.49 KB
/
debug-kit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include <stdlib.h>
#include <string.h>
#include "mgba.h"
#include "no-cash-gba.h"
#define LogInit() mgba_open();
#define LogPrint(string) { mgba_printf(MGBA_LOG_INFO, string); NoCashGBAPrint(string); }
#define LogPrintf(format, ...) { mgba_printf(MGBA_LOG_INFO, format, __VA_ARGS__); NoCashGBAPrintf(format, __VA_ARGS__); }
#define LogWarn(string) { mgba_printf(MGBA_LOG_WARN, string); NoCashGBAPrint("[WARN] "string); }
#define LogWarnf(format, ...) { mgba_printf(MGBA_LOG_WARN, format, __VA_ARGS__); NoCashGBAPrintf("[WARN] "format, __VA_ARGS__); }
#define LogInfo(string) { mgba_printf(MGBA_LOG_INFO, string); NoCashGBAPrint("[INFO] "string); }
#define LogInfof(format, ...) { mgba_printf(MGBA_LOG_INFO, format, __VA_ARGS__); NoCashGBAPrintf("[INFO] "format, __VA_ARGS__); }
#define LogDebug(string) { mgba_printf(MGBA_LOG_DEBUG, string); NoCashGBAPrint("[DEBUG] "string); }
#define LogDebugf(format, ...) { mgba_printf(MGBA_LOG_DEBUG, format, __VA_ARGS__); NoCashGBAPrintf("[DEBUG] "format, __VA_ARGS__); }
#define LogFatal(string) { mgba_printf(MGBA_LOG_FATAL, string); NoCashGBAPrint("[FATAL] "string); abort(); }
#define LogFatalf(format, ...) { mgba_printf(MGBA_LOG_FATAL, format, __VA_ARGS__); NoCashGBAPrintf("[FATAL] "format, __VA_ARGS__); abort(); };
#define LogError(string) { mgba_printf(MGBA_LOG_ERROR, string); NoCashGBAPrint("[ERROR] "string); }
#define LogErrorf(format, ...) { mgba_printf(MGBA_LOG_ERROR, format, __VA_ARGS__); NoCashGBAPrintf("[ERROR] "format, __VA_ARGS__); }
#if (CONFIG_FORCE_PRIENT_ERROR || defined(CONFIG_USE_DEBUG))
#define Fatal(string) LogFatalf("(%s): %s", __func__, string)
#define Fatalf(format, ...) LogFatalf("(%s): "format, __func__, __VA_ARGS__)
#define Error(string) LogErrorf("(%s): %s", __func__, string)
#define Errorf(format, ...) LogErrorf("(%s): "format, __func__, __VA_ARGS__)
#define Assert(condition) if (!(condition)) { Fatal("Assertion failed: " #condition); }
#else
#define Fatal(string)
#define Fatalf(format, ...)
#define Error(string)
#define Errorf(format, ...)
#define Assert(condition)
#endif
#ifdef CONFIG_USE_DEBUG
#define Print(string) LogPrintf("(%s): %s", __func__, string)
#define Printf(format, ...) LogPrintf("(%s): "format, __func__, __VA_ARGS__)
#define Warn(string) LogWarnf("(%s): %s", __func__, string)
#define Warnf(format, ...) LogWarnf("(%s): "format, __func__, __VA_ARGS__)
#define Info(string) LogInfof("(%s): %s", __func__, string)
#define Infof(format, ...) LogInfof("(%s): "format, __func__, __VA_ARGS__)
#define Debug(string) LogDebugf("(%s): %s", __func__, string)
#define Debugf(format, ...) LogDebugf("(%s): "format, __func__, __VA_ARGS__)
#else
#define Print(string)
#define Printf(format, ...)
#define Warn(string)
#define Warnf(format, ...)
#define Info(string)
#define Infof(format, ...)
#define Debug(string)
#define Debugf(format, ...)
#endif
/**
* Custom controller on print
* The debug info inside one file can only show the log in case LOCAL_TRACE=1 is defined in local file
*/
#define LTRACE(x) do { if (LOCAL_TRACE != 0) { Print(x); } } while (0)
#define LTRACEF(x...) do { if (LOCAL_TRACE != 0) { Printf(x); } } while (0)
/**
* FPrint
* Always print to STDOUT regardless on debug config
*/
#define FPrint(string) LogPrintf("(%s): %s", __func__, string)
#define FPrintf(format, ...) LogPrintf("(%s): "format, __func__, __VA_ARGS__)