TEMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Logging.h
Go to the documentation of this file.
1 //===-- temu-c/Logging.h - Logging functions --------------------*- C++ -*-===//
2 //
3 // T-EMU: The Terma Emulator
4 // (c) Terma 2015
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_LOGGING_H
10 #define TEMU_LOGGING_H
11 
12 #include <stdio.h>
13 #include <stdarg.h>
15 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 
63 typedef enum temu_LogLevel {
64  teLL_Fatal = 0,
71 
79 
93 TEMU_API void temu_logSetFunc(void (*LogFunc)(const char *));
94 
101 TEMU_API void temu_logSetDefaultFile(FILE *FP);
102 
107 TEMU_API void temu_logSetColour(int Enable);
108 
114 TEMU_API void temu_logFatal(const void *Obj, const char *Msg, ...)
115  __attribute__((noreturn))
116  __attribute__((format(printf, 2, 3)));
117 
118 TEMU_API void temu_logCritical(const void *Obj, const char *Msg, ...)
119  __attribute__((noreturn))
120  __attribute__((format(printf, 2, 3)))
121  __attribute__((deprecated));
122 
128 TEMU_API void temu_logError(const void *Obj, const char *Msg, ...)
129  __attribute__((format(printf, 2, 3)));
130 
136 TEMU_API void temu_logWarning(const void *Obj, const char *Msg, ...)
137  __attribute__((format(printf, 2, 3)));
138 
144 TEMU_API void temu_logInfo(const void *Obj, const char *Msg, ...)
145  __attribute__((format(printf, 2, 3)));
146 
156 TEMU_API void temu_logDebugFunc(const void *Obj, const char *Msg, ...)
157  __attribute__((format(printf, 2, 3)));
158 
159 #ifdef NDEBUG
160 static inline void
161 temu_logDebug(const void *Obj TEMU_UNUSED, const char *Msg TEMU_UNUSED, ...)
162 {
163  ; // Nothing
164 }
165 
166 #else
167 
168 #define temu_logDebug temu_logDebugFunc
169 
170 #endif
171 
172 
173 /*
174  * New logging API
175  *
176  * The new logging API provides specialised logging for temu_Object
177  * derived classes. They cannot be used by external classes.
178  *
179  * EXPERIMENTAL API New logging API. The New logging API provides
180  * improved logging support. Among the features include custom
181  * logging categories and per device per categor control of the
182  * logging. 16 logging categories are supported, of which the first
183  * 8 are reserved for T-EMU (i.e. global categories).
184  * The next 8 can be controlled per class.
185  *
186  * The reserved categories is split in three main categories (sim,
187  * target and config). These are further subdivided in severity.
188  *
189  * The config category is used to inform users during the
190  * configuration phase or any issues detected with dynamic
191  * configuration. For example, a device with an IRQ property may be
192  * restricted to e.g. 8 different IRQs, if the user sets another value
193  * than the allowed ones then a config error would be logged.
194  *
195  * The target category is for errors triggered by target software, for
196  * example writing a register would be logged with
197  * temu_logTargetDebug(). Note that the category is intended for
198  * direct effects, which is mostly related to MMIO activity.
199  *
200  * The sim category is for other errors caused by e.g. invalid use of
201  * the T-EMU APIs, or other failures.
202  *
203  * A nice feature of this API is the support for user definable
204  * categories. These categories are per class. But category enabling
205  * is controlled per object and globally. A category can be added to a
206  * class using temu_addLoggingCategory() (see Objsys.h), and queried
207  * by id using temu_getLoggingCategory(). The ID can then be used in
208  * calls to temu_logToCategory().
209  *
210  */
211 
212 // User reserved categories are those above 8
213 #define teLC_FirstUserCat 8
214 
215 #define teLC_DefaultCat 0
216 #define teLC_SimCat 1
217 #define teLC_TargetCat 2
218 #define teLC_ConfigCat 3
219 
220 TEMU_API void temu_logToCategoryVA(const void *Obj, unsigned Category, temu_LogLevel Severity,
221  const char *Msg, va_list Args);
222 
226 TEMU_API void temu_logToCategory(const void *Obj, unsigned Category, temu_LogLevel Severity,
227  const char *Msg, ...)
228  __attribute__((format(printf, 4, 5)));
229 
237 TEMU_API void temu_logSimFatal(const void *Obj, const char *Msg, ...)
238  __attribute__((noreturn))
239  __attribute__((format(printf, 2, 3)));
240 
247 TEMU_API void temu_logSimError(const void *Obj, const char *Msg, ...)
248  __attribute__((format(printf, 2, 3)));
249 
256 TEMU_API void temu_logSimWarning(const void *Obj, const char *Msg, ...)
257  __attribute__((format(printf, 2, 3)));
258 
265 TEMU_API void temu_logSimInfo(const void *Obj, const char *Msg, ...)
266  __attribute__((format(printf, 2, 3)));
267 
276 TEMU_API void temu_logTargetFatal(const void *Obj, const char *Msg, ...)
277  __attribute__((noreturn))
278  __attribute__((format(printf, 2, 3)));
279 
280 
287 TEMU_API void temu_logTargetError(const void *Obj, const char *Msg, ...)
288  __attribute__((format(printf, 2, 3)));
289 
296 TEMU_API void temu_logTargetWarning(const void *Obj, const char *Msg, ...)
297  __attribute__((format(printf, 2, 3)));
298 
306 TEMU_API void temu_logTargetInfo(const void *Obj, const char *Msg, ...)
307  __attribute__((format(printf, 2, 3)));
308 
309 
310 
317 TEMU_API void temu_logConfigFatal(const void *Obj, const char *Msg, ...)
318  __attribute__((noreturn))
319  __attribute__((format(printf, 2, 3)));
320 
321 
328 TEMU_API void temu_logConfigError(const void *Obj, const char *Msg, ...)
329  __attribute__((format(printf, 2, 3)));
330 
337 TEMU_API void temu_logConfigWarning(const void *Obj, const char *Msg, ...)
338  __attribute__((format(printf, 2, 3)));
339 
347 TEMU_API void temu_logConfigInfo(const void *Obj, const char *Msg, ...)
348  __attribute__((format(printf, 2, 3)));
349 
350 TEMU_API temu_LogLevel temu_objectGetLogLevel(void *Obj, unsigned Category);
351 TEMU_API void temu_objectSetLogLevel(void *Obj, unsigned Category, temu_LogLevel LogLevel);
352 
353 #ifdef __cplusplus
354 }
355 #endif
356 
357 #endif /* ! TEMU_LOGGING_H */
Debug.
Definition: Logging.h:69
TEMU_API void temu_logToCategory(const void *Obj, unsigned Category, temu_LogLevel Severity, const char *Msg,...) __attribute__((format(printf
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigInfo(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logDebugFunc(const void *Obj, const char *Msg,...) __attribute__((format(printf
temu_logDebugFunc Log a message with debug severity
Fatal, emulator cannot keep on running.
Definition: Logging.h:64
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetError(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void temu_logFatal(const void *Obj, const char *Msg,...) __attribute__((format(printf
temu_logFatal Log a message with fatal severity; The program will terminate after calling this ...
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetFatal(const void *Obj, const char *Msg,...) __attribute__((format(printf
Normal messages.
Definition: Logging.h:68
TEMU_API void TEMU_API void __attribute__((deprecated))
TEMU_API void TEMU_API void temu_logWarning(const void *Obj, const char *Msg,...) __attribute__((format(printf
temu_logWarning Log a message with warning severity
TEMU_API void temu_logSetDefaultFile(FILE *FP)
TEMU_API void temu_objectSetLogLevel(void *Obj, unsigned Category, temu_LogLevel LogLevel)
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetInfo(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void TEMU_API void TEMU_API void temu_logInfo(const void *Obj, const char *Msg,...) __attribute__((format(printf
temu_logInfo Log a message with info severity
TEMU_API void temu_logError(const void *Obj, const char *Msg,...) __attribute__((format(printf
temu_logError Log a message with error severity
TEMU_API void TEMU_API void temu_logCritical(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void temu_logSetLevel(temu_LogLevel LogLevel)
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API temu_LogLevel temu_objectGetLogLevel(void *Obj, unsigned Category)
#define temu_logDebug
Definition: Logging.h:168
TEMU_API void TEMU_API void TEMU_API void temu_logSimError(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigWarning(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void TEMU_API void temu_logSimFatal(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void temu_logSetFunc(void(*LogFunc)(const char *))
Warnings.
Definition: Logging.h:67
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logSimInfo(const void *Obj, const char *Msg,...) __attribute__((format(printf
Error happened, in principle critical but up to user.
Definition: Logging.h:66
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logTargetWarning(const void *Obj, const char *Msg,...) __attribute__((format(printf
temu_LogLevel
Definition: Logging.h:63
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigError(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void temu_logSetColour(int Enable)
TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logSimWarning(const void *Obj, const char *Msg,...) __attribute__((format(printf
TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void TEMU_API void temu_logConfigFatal(const void *Obj, const char *Msg,...) __attribute__((format(printf
Critical, emulator cannot keep on running (deprecated)
Definition: Logging.h:65
TEMU_API void temu_logToCategoryVA(const void *Obj, unsigned Category, temu_LogLevel Severity, const char *Msg, va_list Args)
#define TEMU_API
Definition: Attributes.h:53
#define TEMU_UNUSED
Definition: Attributes.h:31