started to fix the manuals for EBuf. Implemented a
[neuro.git] / include / neuro / debug.h
blob8c80bdb6e2def1597c6ecc231031fa59ff084797
2 /*
3 * libneuro, a light weight abstraction of high or lower libraries
4 * and toolkit for applications.
5 * Copyright (C) 2005-2006 Nicholas Niro, Robert Lemay
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 /* debug.h */
24 #ifndef __DEBUG_H
25 #define __DEBUG_H
27 #include "neuro_engine.h"
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 /*! This function shouldn't be used directly because
34 * Macros were made to fill automatically the arguments
35 * like the file name, function name, line number.
37 extern void Neuro_DebugPrint(char *type, char *control, char *filename, char *funcName, u32 lineNum);
39 extern void Debug_Channel(const char *channel, char *type, char *filename, char *funcName, u32 lineNum, u8 output_detailed, char *control, ...);
41 extern void Debug_VerboseChannel(char *channel);
45 /*! Prints predefined
46 * messages and also makes for a very
47 * easy to call function with only one
48 * argument which extends to 4 automatically
50 #define Debug_Print(x) Neuro_DebugPrint("Debug Message", x, __FILE__, __FUNCTION__, __LINE__)
51 #define Error_Print(x) Neuro_DebugPrint("Error Message", x, __FILE__, __FUNCTION__, __LINE__)
52 #define Info_Print(x) Neuro_DebugPrint("Information Message", x, __FILE__, __FUNCTION__, __LINE__)
55 #define NEURO_ERROR(x, y) Debug_Channel(NEURO_CURRENT_CHANNEL, "Error", \
56 __FILE__, __FUNCTION__, __LINE__, 1, x, y)
58 #define NEURO_WARN(x, y) Debug_Channel(NEURO_CURRENT_CHANNEL, "Warn", \
59 __FILE__, __FUNCTION__, __LINE__, 1, x, y)
61 #define NEURO_TRACE(x, y) Debug_Channel(NEURO_CURRENT_CHANNEL, "Trace", \
62 __FILE__, __FUNCTION__, __LINE__, 1, x, y)
64 #define NEURO_MODULE_CHANNEL(x) static char *NEURO_CURRENT_CHANNEL=x
66 /**
67 * @sdescri flexible formatted text output function with levels
68 * @description depending on the current debug level, will
69 * output those formatted debug informations.
71 * @related Neuro_SetDebugLevel(3)
73 extern void Debug_Val(u8 level, char *control, ...);
75 /**
76 * @sdescri sets the current debug level
78 * @description this function's sole purpose is to set
79 * the current debug level which will only change the
80 * behavior of the function Debug_Val.
82 * @related Debug_Val(3)
84 extern void Neuro_SetDebugLevel(u8 level);
86 /* macro used to check for endianness.
87 * this macro returns 1 if the system
88 * is little endian and 0 if the system
89 * is anything else (big endian hopefully
90 * because we don't support middle endian.
93 #define IsLittleEndian() \
94 ({ \
95 int __i; \
96 char *__p; \
97 __p = (char*)&__i; \
98 __i = 1; \
99 if (__p[0] == 1) \
100 1; \
101 else \
102 0;})
104 extern int IsLittleEndian();
106 extern int Debug_Init();
107 extern void Debug_Clean();
110 #ifdef __cplusplus
112 #endif
114 #endif /* NOT __DEBUG_H */