#include <stdio.h>
#include <glib.h>
-#include "mono-logger.h"
+#include "mono-compiler.h"
+#include "mono-logger-internal.h"
typedef struct {
GLogLevelFlags level;
if(level_stack == NULL) {
level_stack = g_queue_new();
- mono_trace_set_mask_string(getenv("MONO_LOG_MASK"));
- mono_trace_set_level_string(getenv("MONO_LOG_LEVEL"));
+ mono_trace_set_mask_string(g_getenv("MONO_LOG_MASK"));
+ mono_trace_set_level_string(g_getenv("MONO_LOG_LEVEL"));
}
}
mono_trace_push (GLogLevelFlags level, MonoTraceMask mask)
{
if(level_stack == NULL)
- g_error(G_GNUC_PRETTY_FUNCTION ": cannot use mono_trace_push without calling mono_trace_init first.");
+ g_error("%s: cannot use mono_trace_push without calling mono_trace_init first.", __func__);
else {
MonoLogLevelEntry *entry = g_malloc(sizeof(MonoLogLevelEntry));
entry->level = current_level;
mono_trace_pop (void)
{
if(level_stack == NULL)
- g_error(G_GNUC_PRETTY_FUNCTION ": cannot use mono_trace_pop without calling mono_trace_init first.");
+ g_error("%s: cannot use mono_trace_pop without calling mono_trace_init first.", __func__);
else {
if(!g_queue_is_empty (level_stack)) {
MonoLogLevelEntry *entry = (MonoLogLevelEntry*)g_queue_pop_head (level_stack);
}
void
-mono_trace_set_mask_string (char *value)
+mono_trace_set_mask_string (const char *value)
{
int i;
- char *tok;
+ const char *tok;
guint32 flags = 0;
- const char *valid_flags[] = {"asm", "type", "dll", "gc", "cfg", "all", NULL};
+ const char *valid_flags[] = {"asm", "type", "dll", "gc", "cfg", "aot", "security", "all", NULL};
const MonoTraceMask valid_masks[] = {MONO_TRACE_ASSEMBLY, MONO_TRACE_TYPE, MONO_TRACE_DLLIMPORT,
- MONO_TRACE_GC, MONO_TRACE_CONFIG, MONO_TRACE_ALL };
+ MONO_TRACE_GC, MONO_TRACE_CONFIG, MONO_TRACE_AOT, MONO_TRACE_SECURITY,
+ MONO_TRACE_ALL };
if(!value)
return;
- tok = strtok (value, ",");
+ tok = value;
- if(!tok)
- tok = value;
-
- while (tok) {
+ while (*tok) {
+ if (*tok == ',') {
+ tok++;
+ continue;
+ }
for (i = 0; valid_flags[i]; i++) {
- if (strcmp (tok, valid_flags[i]) == 0) {
+ int len = strlen (valid_flags[i]);
+ if (strncmp (tok, valid_flags[i], len) == 0 && (tok[len] == 0 || tok[len] == ',')) {
flags |= valid_masks[i];
+ tok += len;
break;
}
}
- if (!valid_flags[i])
+ if (!valid_flags[i]) {
g_print("Unknown trace flag: %s\n", tok);
-
- tok = strtok (NULL, ",");
+ break;
+ }
}
- if(flags)
- mono_trace_set_mask (flags);
+ mono_trace_set_mask (flags);
+}
+
+/*
+ * mono_trace_is_traced:
+ *
+ * Returns whenever a message with @level and @mask will be printed or not.
+ */
+gboolean
+mono_trace_is_traced (GLogLevelFlags level, MonoTraceMask mask)
+{
+ return (level <= current_level && mask & current_mask);
}