Disabled the debugging functions temporarily.
[neuro.git] / include / neuro / debug.h
blobbe4b26e72ec7ccd7f28343e1109b21a7504fb353
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 enum DEBUG_CLASS
35 DBG_Start,
37 DBG_All,
38 DBG_Warn,
39 DBG_Error,
40 DBG_Trace,
42 DBG_End
45 /*! This function shouldn't be used directly because
46 * Macros were made to fill automatically the arguments
47 * like the file name, function name, line number.
49 extern void Neuro_DebugPrint(char *type, char *control, char *filename, char *funcName, u32 lineNum);
51 extern void Debug_Channel(const char *channel, char *type, char *filename, char *funcName, u32 lineNum, u8 output_detailed, char *control, ...);
53 /* don't call this function directly, use Neuro_SetFilter(3) */
54 extern void Neuro_CoreSetFilter(char *project_name, char *channel);
56 #define Neuro_SetFilter(x) Neuro_CoreSetFilter(NEURO_PROJECT_NAMESPACE, x)
58 extern void Neuro_DebugChannel(const char *project_name, const char *channel, char *type, char *filename, char *funcName, u32 lineNum, u8 output_detailed, char *control, ...);
60 /*! Prints predefined
61 * messages and also makes for a very
62 * easy to call function with only one
63 * argument which extends to 4 automatically
65 #define Debug_Print(x) Neuro_DebugPrint("Debug Message", x, __FILE__, __FUNCTION__, __LINE__)
66 #define Error_Print(x) Neuro_DebugPrint("Error Message", x, __FILE__, __FUNCTION__, __LINE__)
67 #define Info_Print(x) Neuro_DebugPrint("Information Message", x, __FILE__, __FUNCTION__, __LINE__)
69 /* attempt to make developpers be warned when they used
70 * NEURO_ERROR, _WARN or _TRACE without first calling
71 * NEURO_MODULE_CHANNEL()
73 /*#if ! NEURO_CURRENT_CHANNEL
74 #error "To Make use of libneuro's debugging channels,\
75 you need to set a string to NEURO_MODULE_CHANNEL("<your string>")\
76 to make the process work. example : NEURO_MODULE_CHANNEL("graphics")"
77 #endif*/ /* NOT NEURO_CURRENT_CHANNEL */
79 #define NEURO_ERROR(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, \
80 NEURO_CURRENT_CHANNEL, \
81 "Error", __FILE__, __FUNCTION__, __LINE__, 1, x, y)
83 #define NEURO_WARN(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, \
84 NEURO_CURRENT_CHANNEL, \
85 "Warn", __FILE__, __FUNCTION__, __LINE__, 1, x, y)
87 #define NEURO_TRACE(x, y) Neuro_DebugChannel(NEURO_PROJECT_NAMESPACE, \
88 NEURO_CURRENT_CHANNEL, \
89 "Trace", __FILE__, __FUNCTION__, __LINE__, 1, x, y)
91 #define NEURO_PROJECT_NAME(x) char *NEURO_PROJECT_NAMESPACE=x
93 #define NEURO_MODULE_CHANNEL(x) static char *NEURO_CURRENT_CHANNEL=x
95 /**
96 * @sdescri flexible formatted text output function with levels
97 * @description depending on the current debug level, will
98 * output those formatted debug informations.
100 * @related Neuro_SetDebugLevel(3)
102 extern void Debug_Val(u8 level, char *control, ...);
104 /**
105 * @sdescri sets the current debug level
107 * @description this function's sole purpose is to set
108 * the current debug level which will only change the
109 * behavior of the function Debug_Val.
111 * @related Debug_Val(3)
113 extern void Neuro_SetDebugLevel(u8 level);
115 /* macro used to check for endianness.
116 * this macro returns 1 if the system
117 * is little endian and 0 if the system
118 * is anything else (big endian hopefully
119 * because we don't support middle endian.
122 #define IsLittleEndian() \
123 ({ \
124 int __i; \
125 char *__p; \
126 __p = (char*)&__i; \
127 __i = 1; \
128 if (__p[0] == 1) \
129 1; \
130 else \
131 0;})
133 extern int IsLittleEndian();
135 extern int Debug_Init();
136 extern void Debug_Clean();
139 #ifdef __cplusplus
141 #endif
143 #endif /* NOT __DEBUG_H */