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