annotate src/debug.h @ 673:fbebf5cf4a55

Do not use printf() directly but use new wrapper function log_printf() instead.
author zas_
date Fri, 16 May 2008 12:16:49 +0000
parents b78a91d0779e
children c0dda0ffb931
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
1 /*
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
2 * Geeqie
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
3 * Copyright (C) 2008 The Geeqie Team
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
4 *
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
5 * Authors: Vladimir Nadvornik, Laurent Monin
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
6 *
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
8 * Please read the included file COPYING for more information.
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
9 * This software comes with no warranty of any kind, use at your own risk!
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
10 */
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
11
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
12 #ifndef DEBUG_H
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
13 #define DEBUG_H
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
14
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
15 #define DOMAIN_DEBUG "debug"
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
16 #define DOMAIN_INFO "info"
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
17
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
18 gint log_domain_printf(const char *domain, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
19 #define log_printf(...) log_domain_printf(DOMAIN_INFO, __VA_ARGS__)
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
20
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
21
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
22
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
23
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
24 #if 1 /* set to 0 to disable compilation of debugging code and related options */
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
25 # ifndef DEBUG
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
26 # define DEBUG 1
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
27 # endif
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
28 #endif
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
29
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
30 #ifdef DEBUG
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
31
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
32 #define DEBUG_LEVEL_MIN 0
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
33 #define DEBUG_LEVEL_MAX 4
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
34
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
35 gint get_debug_level(void);
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
36 void set_debug_level(gint new_level);
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
37 void debug_level_add(gint delta);
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
38 gint required_debug_level(gint level);
509
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
39 const gchar *get_exec_time(void);
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
40 void init_exec_time(void);
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
41
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
42 #define DEBUG_N(n, ...) do \
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
43 { \
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
44 gint debug_level = get_debug_level(); \
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
45 if (debug_level >= (n)) \
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
46 { \
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
47 if (debug_level != 1) log_domain_printf(DOMAIN_DEBUG, "%s:%d: ", __FILE__, __LINE__); \
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
48 log_domain_printf(DOMAIN_DEBUG, __VA_ARGS__); \
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 509
diff changeset
49 log_domain_printf(DOMAIN_DEBUG, "\n"); \
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
50 } \
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
51 } while (0)
509
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
52
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
53 #else /* DEBUG */
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
54
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
55 #define get_debug_level() (0)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
56 #define set_debug_level(new_level) do { } while(0)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
57 #define debug_level_add(delta) do { } while(0)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
58 #define required_debug_level(level) (0)
509
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
59 #define get_exec_time() ""
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
60 #define init_exec_time() do { } while(0)
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
61
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
62 #define DEBUG_N(n, ...) do { } while(0)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
63
509
b78a91d0779e Move get_exec_time() to debug.{c,h}.
zas_
parents: 507
diff changeset
64 #endif /* DEBUG */
507
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
65
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
66 #define DEBUG_0(...) DEBUG_N(0, __VA_ARGS__)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
67 #define DEBUG_1(...) DEBUG_N(1, __VA_ARGS__)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
68 #define DEBUG_2(...) DEBUG_N(2, __VA_ARGS__)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
69 #define DEBUG_3(...) DEBUG_N(3, __VA_ARGS__)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
70 #define DEBUG_4(...) DEBUG_N(4, __VA_ARGS__)
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
71
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
72
135570a8bd96 Move debug macros from main.h to new debug.h.
zas_
parents:
diff changeset
73 #endif /* DEBUG_H */