KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
dbglog.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 kos/dbglog.h
4 Copyright (C)2004 Megan Potter
5
6*/
7
8/** \file kos/dbglog.h
9 \brief A debugging log.
10 \ingroup logging
11
12 This file contains declarations related a debugging log. This log can be
13 used to restrict log messages, for instance to make it so that only the most
14 urgent of messages get printed for a release version of a program.
15
16 \author Megan Potter
17*/
18
19#ifndef __KOS_DBGLOG_H
20#define __KOS_DBGLOG_H
21
22#include <kos/cdefs.h>
23__BEGIN_DECLS
24
25#include <kos/opts.h>
26
27/** \defgroup logging Logging
28 \brief KOS's Logging API
29 \ingroup debugging
30*/
31
32/** \brief Kernel debugging printf.
33 \ingroup logging
34
35 This function is similar to printf(), but filters its output through a log
36 level check before being printed. This way, you can set the level of debug
37 info you want to see (or want your users to see).
38
39 \param level The level of importance of this message.
40 \param fmt Message format string.
41 \param ... Format arguments
42 \see dbglog_levels
43*/
44void __real_dbglog(int level, const char *fmt, ...) __printflike(2, 3);
45
46/* This wrapper allows for the garbage collection of unneeded debug data */
47#define dbglog(lvl, ...) \
48do { \
49 if ((lvl) <= DBGLOG_LEVEL_SUPPORT) \
50 __real_dbglog(lvl, __VA_ARGS__); \
51} while(0)
52
53/** \defgroup dbglog_levels Log Levels
54 \brief dbglog severity levels
55 \ingroup logging
56
57 This is the list of levels that are allowed to be passed into the dbglog()
58 function, representing different levels of importance.
59
60 For `DBG_SOURCE()` pass to it a define that controls specific debugging
61 and if the define is defined, the logging will be outputted. If not defined
62 the messages will only be outputted if the level is set to `DBG_MAX`.
63
64 @{
65*/
66#define DBG_DISABLED -1 /**< \brief No output allowed */
67#define DBG_DEAD 0 /**< \brief The system is dead */
68#define DBG_CRITICAL 1 /**< \brief A critical error message */
69#define DBG_ERROR 2 /**< \brief A normal error message */
70#define DBG_WARNING 3 /**< \brief Potential problem */
71#define DBG_NOTICE 4 /**< \brief Normal but significant */
72#define DBG_INFO 5 /**< \brief Informational messages */
73#define DBG_DEBUG 6 /**< \brief User debug messages */
74#define DBG_KDEBUG 7 /**< \brief Kernel debug messages */
75#define DBG_MAX 8 /**< \brief All debug outputted */
76
77#define DBG_SOURCE(x) (__is_defined(x) ? DBG_DEAD : DBG_MAX) /**< \brief Verbose debugging of specific systems */
78/** @} */
79
80/** \brief Set the debugging log level.
81 \ingroup logging
82
83 This function sets the level for which dbglog() will ignore messages for if
84 the message has a higher level. This runtime setting does not override the
85 `DBGLOG_LEVEL_SUPPORT` define.
86
87 \param level The level to stop paying attention after.
88 \see dbglog_levels
89*/
90void dbglog_set_level(int level);
91
92__END_DECLS
93
94#endif /* __KOS_DBGLOG_H */
95
Various common macros used throughout the codebase.
void __real_dbglog(int level, const char *fmt,...) __printflike(2
Kernel debugging printf.
void dbglog_set_level(int level)
Set the debugging log level.
Compile-time options regarding debugging and other topics.