throw exceptions, fixes events, missing methods
[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         MONO_TRACE_CONFIG               = (1<<4),
12         MONO_TRACE_AOT          = (1<<5),
13         MONO_TRACE_ALL                  = MONO_TRACE_ASSEMBLY |
14                                           MONO_TRACE_TYPE |
15                                           MONO_TRACE_DLLIMPORT |
16                                           MONO_TRACE_GC |
17                           MONO_TRACE_CONFIG |
18                           MONO_TRACE_AOT
19 } MonoTraceMask;
20
21 void 
22 mono_trace_cleanup (void);
23
24 void 
25 mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...);
26
27 void 
28 mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args);
29
30 void 
31 mono_trace_set_level (GLogLevelFlags level);
32
33 void 
34 mono_trace_set_level_string (const char *value);
35
36 void 
37 mono_trace_set_mask (MonoTraceMask mask);
38
39 void 
40 mono_trace_set_mask_string (char *value);
41
42 void 
43 mono_trace_push (GLogLevelFlags level, MonoTraceMask mask);
44
45 void 
46 mono_trace_pop (void);
47
48 #ifdef G_HAVE_ISO_VARARGS
49 #define mono_trace_error(...)   mono_trace(G_LOG_LEVEL_ERROR, \
50                                                                                         __VA_ARGS__)
51 #define mono_trace_warning(...) mono_trace(G_LOG_LEVEL_WARNING, \
52                                                                                         __VA_ARGS__)
53 #define mono_trace_message(...) mono_trace(G_LOG_LEVEL_MESSAGE, \
54                                                                                         __VA_ARGS__)
55 #elif defined(G_HAVE_GNUC_VARARGS)
56 #define mono_trace_error(format...)     mono_trace(G_LOG_LEVEL_ERROR, \
57                                                                                         format)
58 #define mono_trace_warning(format...) mono_trace(G_LOG_LEVEL_WARNING, \
59                                                                                         format)
60 #define mono_trace_message(format...) mono_trace(G_LOG_LEVEL_MESSAGE, \
61                                                                                         format)
62 #else /* no varargs macros */
63 static void
64 mono_trace_error(MonoTraceMask mask, const char *format, ...)
65 {
66         va_list args;
67         va_start (args, format);
68         mono_tracev(G_LOG_LEVEL_ERROR, mask, format, args);
69         va_end (args);
70 }
71
72 static void
73 mono_trace_warning(MonoTraceMask mask, const char *format, ...)
74 {
75         va_list args;
76         va_start (args, format);
77         mono_tracev(G_LOG_LEVEL_WARNING, mask, format, args);
78         va_end (args);
79 }
80
81 static void
82 mono_trace_message(MonoTraceMask mask, const char *format, ...)
83 {
84         va_list args;
85         va_start (args, format);
86         mono_tracev(G_LOG_LEVEL_MESSAGE, mask, format, args);
87         va_end (args);
88 }
89
90 #endif /* !__GNUC__ */
91
92 #endif /* __MONO_LOGGER_H__ */