2004-06-08 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / utils / mono-logger.h
1 #ifndef __MONO_LOGGER_H__
2 #define __MONO_LOGGER_H__
3
4 #include <glib.h>
5
6 typedef enum {
7         MONO_TRACE_ASSEMBLY             = (1<<0),
8         MONO_TRACE_TYPE                 = (1<<1),
9         MONO_TRACE_DLLIMPORT    = (1<<2),
10         MONO_TRACE_GC                   = (1<<3),
11
12         MONO_TRACE_ALL                  =   MONO_TRACE_ASSEMBLY |
13                                                                 MONO_TRACE_TYPE |
14                                                                 MONO_TRACE_DLLIMPORT |
15                                                                 MONO_TRACE_GC
16 } MonoTraceMask;
17
18 void 
19 mono_trace_cleanup (void);
20
21 void 
22 mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...);
23
24 void 
25 mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args);
26
27 void 
28 mono_trace_set_level (GLogLevelFlags level);
29
30 void 
31 mono_trace_set_level_string (const char *value);
32
33 void 
34 mono_trace_set_mask (MonoTraceMask mask);
35
36 void 
37 mono_trace_set_mask_string (char *value);
38
39 void 
40 mono_trace_push (GLogLevelFlags level, MonoTraceMask mask);
41
42 void 
43 mono_trace_pop (void);
44
45 #ifdef G_HAVE_ISO_VARARGS
46 #define mono_trace_error(...)   mono_trace(G_LOG_LEVEL_ERROR, \
47                                                                                         __VA_ARGS__)
48 #define mono_trace_warning(...) mono_trace(G_LOG_LEVEL_WARNING, \
49                                                                                         __VA_ARGS__)
50 #define mono_trace_message(...) mono_trace(G_LOG_LEVEL_MESSAGE, \
51                                                                                         __VA_ARGS__)
52 #elif defined(G_HAVE_GNUC_VARARGS)
53 #define mono_trace_error(format...)     mono_trace(G_LOG_LEVEL_ERROR, \
54                                                                                         format)
55 #define mono_trace_warning(format...) mono_trace(G_LOG_LEVEL_WARNING, \
56                                                                                         format)
57 #define mono_trace_message(format...) mono_trace(G_LOG_LEVEL_MESSAGE, \
58                                                                                         format)
59 #else /* no varargs macros */
60 static void
61 mono_trace_error(MonoTraceMask mask, const char *format, ...)
62 {
63         va_list args;
64         va_start (args, format);
65         mono_tracev(G_LOG_LEVEL_ERROR, mask, format, args);
66         va_end (args);
67 }
68
69 static void
70 mono_trace_warning(MonoTraceMask mask, const char *format, ...)
71 {
72         va_list args;
73         va_start (args, format);
74         mono_tracev(G_LOG_LEVEL_WARNING, mask, format, args);
75         va_end (args);
76 }
77
78 static void
79 mono_trace_message(MonoTraceMask mask, const char *format, ...)
80 {
81         va_list args;
82         va_start (args, format);
83         mono_tracev(G_LOG_LEVEL_MESSAGE, mask, format, args);
84         va_end (args);
85 }
86
87 #endif /* !__GNUC__ */
88
89 #endif /* __MONO_LOGGER_H__ */