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