QOF: qoflog.h Source File

QOF 0.7.5

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

qoflog.h
Go to the documentation of this file.
1 /***************************************************************************
2 * qof-log.h
3 *
4 * Mon Nov 21 14:35:26 2005
5 * Author: Rob Clark (rclark@cs.hmc.edu)
6 * Copyright (C) 1998-2003 Linas Vepstas <linas@linas.org>
7 * Copyright 2005 Neil Williams
8 * linux@codehelp.co.uk
9 ****************************************************************************/
10 /*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * 02110-1301, USA
25 */
26
34 #ifndef _QOF_LOG_H
35 #define _QOF_LOG_H
36
37 #include <stdarg.h>
38 #include <stdio.h>
39 #include "qofutil.h"
40
41 #define QOF_MOD_ENGINE "qof-engine"
42
43 #define LOG_LEVEL_LIST(_) \
44 _(QOF_LOG_FATAL, = 0) \
45 _(QOF_LOG_ERROR, = 1) \
46 _(QOF_LOG_WARNING, = 2) \
47 _(QOF_LOG_INFO, = 3) \
48 _(QOF_LOG_DEBUG, = 4) \
49 _(QOF_LOG_DETAIL, = 5) \
50 _(QOF_LOG_TRACE, = 6)
51
58 DEFINE_ENUM (QofLogLevel, LOG_LEVEL_LIST)
59
60
64 AS_STRING_DEC (QofLogLevel, LOG_LEVEL_LIST)
65
70 FROM_STRING_DEC (QofLogLevel, LOG_LEVEL_LIST)
71
73 void qof_log_add_indent (void);
74
76 gint qof_log_get_indent (void);
77
82 void qof_log_drop_indent (void);
83
94 void qof_log_init (void);
95
101 void qof_log_set_level (QofLogModule module, QofLogLevel level);
102
123 void qof_log_set_level_registered (QofLogLevel level);
124
131 void qof_log_set_file (FILE * outfile);
132
137 void qof_log_init_filename (const gchar * logfilename);
138
140 void qof_log_shutdown (void);
141
145 const gchar *qof_log_prettify (const gchar * name);
146
148 gboolean qof_log_check (QofLogModule log_module, QofLogLevel log_level);
149
151 void qof_log_set_default (QofLogLevel log_level);
152
153 typedef void (*QofLogCB) (QofLogModule log_module,
154 QofLogLevel * log_level, gpointer user_data);
155
161 void qof_log_module_foreach (QofLogCB cb, gpointer data);
162
164 gint qof_log_module_count (void);
165
166 #define FUNK qof_log_prettify(__FUNCTION__)
167
179 #define FATAL(format, args...) do { \
180 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \
181 "Fatal Error: %s(): " format, FUNK , ## args); \
182 } while (0)
183
185 #define PERR(format, args...) do { \
186 if (qof_log_check (log_module, QOF_LOG_ERROR)) { \
187 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
188 "Error: %s(): " format, FUNK , ## args); \
189 } \
190 } while (0)
191
193 #define PWARN(format, args...) do { \
194 if (qof_log_check (log_module, QOF_LOG_WARNING)) { \
195 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \
196 "Warning: %s(): " format, FUNK , ## args); \
197 } \
198 } while (0)
199
201 #define PINFO(format, args...) do { \
202 if (qof_log_check (log_module, QOF_LOG_INFO)) { \
203 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \
204 "Info: %s(): " format, \
205 FUNK , ## args); \
206 } \
207 } while (0)
208
210 #define DEBUG(format, args...) do { \
211 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
212 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
213 "Debug: %s(): " format, \
214 FUNK , ## args); \
215 } \
216 } while (0)
217
219 #define ENTER(format, args...) do { \
220 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
221 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
222 "Enter in %s: %s()" format, __FILE__, \
223 FUNK , ## args); \
224 qof_log_add_indent(); \
225 } \
226 } while (0)
227
229 #define LEAVE(format, args...) do { \
230 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
231 qof_log_drop_indent(); \
232 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
233 "Leave: %s()" format, \
234 FUNK , ## args); \
235 } \
236 } while (0)
237
239 #define TRACE(format, args...) do { \
240 if (qof_log_check (log_module, QOF_LOG_TRACE)) { \
241 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
242 "Trace: %s(): " format, FUNK , ## args); \
243 } \
244 } while (0)
245
246 #define DEBUGCMD(x) do { \
247 if (qof_log_check (log_module, QOF_LOG_DEBUG)) { \
248 (x); \
249 } \
250 } while (0)
251
252 #endif /* _QOF_LOG_H */
253
qof_log_init_filename
void qof_log_init_filename(const gchar *logfilename)
Definition: qoflog.c:144
qof_log_get_indent
gint qof_log_get_indent(void)
Definition: qoflog.c:51
qof_log_check
gboolean qof_log_check(QofLogModule log_module, QofLogLevel log_level)
Definition: qoflog.c:204
qof_log_prettify
const gchar * qof_log_prettify(const gchar *name)
Definition: qoflog.c:177
qof_log_shutdown
void qof_log_shutdown(void)
Definition: qoflog.c:159
QofLogLevel
QofLogLevel
Definition: qoflog.h:58
qof_log_init
void qof_log_init(void)
Definition: qoflog.c:74
qof_log_module_foreach
void qof_log_module_foreach(QofLogCB cb, gpointer data)
Definition: qoflog.c:273
qof_log_module_count
gint qof_log_module_count(void)
Definition: qoflog.c:287
qof_log_set_default
void qof_log_set_default(QofLogLevel log_level)
Definition: qoflog.c:232
qof_log_add_indent
void qof_log_add_indent(void)
Definition: qoflog.c:45
qof_log_drop_indent
void qof_log_drop_indent(void)
Definition: qoflog.c:57
qof_log_set_level_registered
void qof_log_set_level_registered(QofLogLevel level)
Definition: qoflog.c:120
qof_log_set_level
void qof_log_set_level(QofLogModule module, QofLogLevel level)
Definition: qoflog.c:96
qofutil.h
QOF utility functions.
QofLogModule
const gchar * QofLogModule
Definition: qofid.h:85
qof_log_set_file
void qof_log_set_file(FILE *outfile)
Definition: qoflog.c:133