[Mono-list] Patch for selective logging

Jerome Laban jlaban@wanadoo.fr
Sun, 2 Mar 2003 17:45:22 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_077F_01C2E0E3.7F869680
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0780_01C2E0E3.7F869680"


------=_NextPart_001_0780_01C2E0E3.7F869680
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi everyone,=20

    Here is a possible patch for selective logging to console. Now, =
messages like "cant resolve internal call to" can be removed. They not =
only appear when corlib and mono runtime are out of sync, they also =
appear when embedding mono, and this is annoying.

    So here are 3 files:=20
        - A diff for some mono files to call the new logging api,
        - Two files for the new logging functions. (to place in =
./mono/mono/utils)

Two options are also added to command line :
  a.. --log-level=3DVALUE, for which the possible values are from 2 to 7 =
(mapped from the G_LOG_LEVEL_XXX enum). 2 stands for error messages =
only, 7 for error+critical+warning+message+info+debug.
  b.. --log-mask=3DMASK, this option is not listed in the usage infos, =
it is the decimal value of the mask. See mono-logger.h for more infos on =
possible values.
For code usage sample, see loader.c line 72.

To remove messages when using mcs, add --log-level=3D3 in the mcs script =
file.

This is only a patch proposition, is that okay lupus / gonzalo ?

The patch also includes header updates for object.h and threads.h that =
were using the "this" keyword as a function parameter, which is =
incompatible for inclusion in a C++ source file.

Jerome.
------=_NextPart_001_0780_01C2E0E3.7F869680
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi everyone, </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; Here is a possible patch for =
selective=20
logging to console. Now, messages like "cant resolve internal call to" =
can be=20
removed. They not only appear when corlib and mono runtime are out of =
sync, they=20
also appear when embedding mono, and this is annoying.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; So here are 3 files: =
</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -&nbsp;A diff =
for some=20
mono files to call the new logging api,</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Two =
files for the=20
new logging functions. (to place in ./mono/mono/utils)</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Two options are also added to command line =
:</FONT></DIV>
<UL>
  <LI><FONT size=3D2><STRONG>--log-level=3DVALUE</STRONG>, for which the =

  possible&nbsp;values are&nbsp;from&nbsp;2 to 7&nbsp;(mapped from the=20
  G_LOG_LEVEL_XXX&nbsp;enum).&nbsp;2 stands for&nbsp;error messages =
only, 7=20
  for&nbsp;error+critical+warning+message+info+debug.</FONT></LI>
  <LI><FONT size=3D2><STRONG>--log-mask=3DMASK</STRONG>, this option is =
not listed=20
  in the usage infos, it is the decimal value of the mask.=20
  See&nbsp;mono-logger.h for more infos on possible =
values.</FONT></LI></UL>
<DIV><FONT size=3D2>For code usage sample, see loader.c line =
72.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>To remove messages when using mcs, add =
--log-level=3D3 in the=20
mcs script&nbsp;file.</FONT></DIV>
<DIV><FONT size=3D2>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>This is only a patch proposition, is that okay lupus =
/ gonzalo=20
?</FONT></DIV>
<DIV>&nbsp;</DIV></FONT></DIV>
<DIV><FONT size=3D2>The patch also includes header updates for object.h =
and=20
threads.h that were using the "this" keyword as a =
function&nbsp;parameter, which=20
is incompatible for inclusion in a C++ source&nbsp;file.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Jerome.</FONT></DIV></BODY></HTML>

------=_NextPart_001_0780_01C2E0E3.7F869680--

------=_NextPart_000_077F_01C2E0E3.7F869680
Content-Type: application/octet-stream;
	name="logcpp.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="logcpp.diff"

Index: mono/jit/mono.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/jit/mono.c,v=0A=
retrieving revision 1.50=0A=
diff -u -r1.50 mono.c=0A=
--- mono/jit/mono.c	21 Feb 2003 22:04:49 -0000	1.50=0A=
+++ mono/jit/mono.c	2 Mar 2003 16:07:15 -0000=0A=
@@ -17,6 +17,7 @@=0A=
 #include "mono/metadata/mono-config.h"=0A=
 #include <mono/metadata/profiler-private.h>=0A=
 #include <mono/metadata/environment.h>=0A=
+#include <mono/utils/mono-logger.h>=0A=
 #include <mono/os/util.h>=0A=
 #include <locale.h>=0A=
 =0A=
@@ -156,6 +157,7 @@=0A=
 		 "                         @imagename              compile the given =
image\n"=0A=
 		 "    --ncompile NUM     compile methods NUM times (default: 1000)\n"=0A=
 		 "    --noboundcheck     Disables bound checks\n"=0A=
+		 "    --log-level=3DLEVEL  Sets the logging level (Default: 5, =
Message)\n"=0A=
 		 "\n"=0A=
 		 "Development:\n"=0A=
 		 "    --debug[=3DFORMAT]   write a debugging file.  FORMAT is one =
of:\n"=0A=
@@ -269,6 +271,9 @@=0A=
 	setlocale(LC_ALL, "");=0A=
 	g_log_set_always_fatal (G_LOG_LEVEL_ERROR);=0A=
 	g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR);=0A=
+=0A=
+	mono_trace_init ();=0A=
+	mono_trace_push (G_LOG_LEVEL_MESSAGE, MONO_TRACE_ALL);=0A=
 	=0A=
 	if (argc < 2)=0A=
 		usage (argv [0]);=0A=
@@ -351,6 +356,24 @@=0A=
 			precompile_classes =3D g_list_append (precompile_classes, argv =
[++i]);=0A=
 		} else if (strcmp (argv [i], "--verbose") =3D=3D 0) {=0A=
 			verbose =3D TRUE;;=0A=
+		} else if (strncmp (argv [i], "--log-level=3D", 12) =3D=3D 0) {=0A=
+			const char *levelstr =3D &argv [i][12];=0A=
+			int level =3D G_LOG_LEVEL_MESSAGE;=0A=
+=0A=
+			if(levelstr) {=0A=
+				if(sscanf (levelstr, "%d", &level)) {=0A=
+					mono_trace_set_level ((1<<level));=0A=
+				}=0A=
+			}=0A=
+		} else if (strncmp (argv [i], "--log-mask=3D", 11) =3D=3D 0) {=0A=
+			const char *maskstr =3D &argv [i][11];=0A=
+			int mask =3D MONO_TRACE_ALL;=0A=
+=0A=
+			if(maskstr) {=0A=
+				if(sscanf (maskstr, "%d", &mask)) {=0A=
+					mono_trace_set_mask (mask);=0A=
+				}=0A=
+			}=0A=
 		} else if (strcmp (argv [i], "--fast-iconv") =3D=3D 0) {=0A=
 			mono_use_fast_iconv =3D TRUE;=0A=
 		} else=0A=
@@ -394,6 +417,8 @@=0A=
 =0A=
 	/* Look up return value from System.Environment.ExitCode */=0A=
 	retval=3Dmono_environment_exitcode_get ();=0A=
-	=0A=
+=0A=
+	mono_trace_cleanup ();=0A=
+=0A=
 	return retval;=0A=
 }=0A=
Index: mono/metadata/loader.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/metadata/loader.c,v=0A=
retrieving revision 1.89=0A=
diff -u -r1.89 loader.c=0A=
--- mono/metadata/loader.c	9 Feb 2003 17:45:09 -0000	1.89=0A=
+++ mono/metadata/loader.c	2 Mar 2003 16:07:16 -0000=0A=
@@ -32,6 +32,7 @@=0A=
 #include <mono/metadata/class.h>=0A=
 #include <mono/metadata/debug-helpers.h>=0A=
 #include <mono/metadata/reflection.h>=0A=
+#include <mono/utils/mono-logger.h>=0A=
 =0A=
 static gboolean dummy_icall =3D TRUE;=0A=
 =0A=
@@ -68,11 +69,11 @@=0A=
 		return ves_icall_dummy;=0A=
 =0A=
 	if (!method) {=0A=
-		g_warning ("can't resolve internal call, method is null");=0A=
+		mono_trace_warning (MONO_TRACE_TYPE, "can't resolve internal call, =
method is null");=0A=
 	}=0A=
 =0A=
 	if (!icall_hash) {=0A=
-		g_warning ("icall_hash not initialized");=0A=
+		mono_trace_warning (MONO_TRACE_TYPE, "icall_hash not initialized");=0A=
 		g_assert_not_reached ();=0A=
 	}=0A=
 =0A=
@@ -90,12 +91,13 @@=0A=
 		else=0A=
 			name =3D g_strconcat (method->klass->name, "::", method->name, "(", =
tmpsig, ")", NULL);=0A=
 		if (!(res =3D g_hash_table_lookup (icall_hash, name))) {=0A=
-			g_warning ("cant resolve internal call to \"%s\" (tested without =
signature also)", name);=0A=
-			g_print ("\nYour mono runtime and corlib are out of sync.\n");=0A=
-			g_print ("When you update one from cvs you need to update, compile =
and install\nthe other too.\n");=0A=
-			g_print ("Do not report this as a bug unless you're sure you have =
updated correctly:\nyou probably have a broken mono install.\n");=0A=
-			g_print ("If you see other errors or faults after this message they =
are probably related\n");=0A=
-			g_print ("and you need to fix your mono install first.\n");=0A=
+			mono_trace_warning (MONO_TRACE_TYPE, "cant resolve internal call to =
\"%s\" (tested without signature also)", name);=0A=
+			mono_trace_message (MONO_TRACE_TYPE, =0A=
+				"\nYour mono runtime and corlib are out of sync.\n"=0A=
+				"When you update one from cvs you need to update, compile and =
install\nthe other too.\n"=0A=
+				"Do not report this as a bug unless you're sure you have updated =
correctly:\nyou probably have a broken mono install.\n"=0A=
+				"If you see other errors or faults after this message they are =
probably related\n"=0A=
+				"and you need to fix your mono install first.\n");=0A=
 =0A=
 			g_free (name);=0A=
 			g_free (tmpsig);=0A=
@@ -142,7 +144,7 @@=0A=
 	case MEMBERREF_PARENT_TYPEREF:=0A=
 		klass =3D mono_class_from_typeref (image, MONO_TOKEN_TYPE_REF | =
nindex);=0A=
 		if (!klass) {=0A=
-			g_warning ("Missing field %s in typeref index %d", fname, nindex);=0A=
+			mono_trace_warning (MONO_TRACE_TYPE, "Missing field %s in typeref =
index %d", fname, nindex);=0A=
 			return NULL;=0A=
 		}=0A=
 		mono_class_init (klass);=0A=
@@ -228,14 +230,14 @@=0A=
 	case MEMBERREF_PARENT_TYPEREF:=0A=
 		klass =3D mono_class_from_typeref (image, MONO_TOKEN_TYPE_REF | =
nindex);=0A=
 		if (!klass) {=0A=
-			g_warning ("Missing method %s in assembly %s typeref index %d", =
mname, image->name, nindex);=0A=
+			mono_trace_warning (MONO_TRACE_TYPE, "Missing method %s in assembly =
%s typeref index %d", mname, image->name, nindex);=0A=
 			mono_metadata_free_method_signature (sig);=0A=
 			return NULL;=0A=
 		}=0A=
 		mono_class_init (klass);=0A=
 		method =3D find_method (klass, mname, sig);=0A=
 		if (!method)=0A=
-			g_warning ("Missing method %s in assembly %s typeref index %d", =
mname, image->name, nindex);=0A=
+			mono_trace_warning (MONO_TRACE_TYPE, "Missing method %s in assembly =
%s typeref index %d", mname, image->name, nindex);=0A=
 		mono_metadata_free_method_signature (sig);=0A=
 		return method;=0A=
 	case MEMBERREF_PARENT_TYPESPEC: {=0A=
@@ -255,7 +257,7 @@=0A=
 			mono_class_init (klass);=0A=
 			method =3D find_method (klass, mname, sig);=0A=
 			if (!method)=0A=
-				g_warning ("Missing method %s in assembly %s typeref index %d", =
mname, image->name, nindex);=0A=
+				mono_trace_warning (MONO_TRACE_TYPE, "Missing method %s in assembly =
%s typeref index %d", mname, image->name, nindex);=0A=
 			mono_metadata_free_method_signature (sig);=0A=
 			return method;=0A=
 		}=0A=
@@ -302,14 +304,14 @@=0A=
 	case MEMBERREF_PARENT_TYPEDEF:=0A=
 		klass =3D mono_class_get (image, MONO_TOKEN_TYPE_DEF | nindex);=0A=
 		if (!klass) {=0A=
-			g_warning ("Missing method %s in assembly %s typedef index %d", =
mname, image->name, nindex);=0A=
+			mono_trace_warning (MONO_TRACE_TYPE, "Missing method %s in assembly =
%s typedef index %d", mname, image->name, nindex);=0A=
 			mono_metadata_free_method_signature (sig);=0A=
 			return NULL;=0A=
 		}=0A=
 		mono_class_init (klass);=0A=
 		method =3D find_method (klass, mname, sig);=0A=
 		if (!method)=0A=
-			g_warning ("Missing method %s in assembly %s typeref index %d", =
mname, image->name, nindex);=0A=
+			mono_trace_warning (MONO_TRACE_TYPE, "Missing method %s in assembly =
%s typeref index %d", mname, image->name, nindex);=0A=
 		mono_metadata_free_method_signature (sig);=0A=
 		return method;=0A=
 	default:=0A=
@@ -418,7 +420,7 @@=0A=
 	if (!gmodule) {=0A=
 		gchar *error =3D g_strdup (g_module_error ());=0A=
 		if (!(gmodule=3Dg_module_open (scope, G_MODULE_BIND_LAZY))) {=0A=
-			g_warning ("Failed to load library %s (%s): %s", full_name, scope, =
error);=0A=
+			mono_trace_warning (MONO_TRACE_DLLIMPORT, "Failed to load library %s =
(%s): %s", full_name, scope, error);=0A=
 			g_free (error);=0A=
 			g_free (full_name);=0A=
 			return NULL;=0A=
@@ -430,7 +432,7 @@=0A=
 	g_module_symbol (gmodule, import, &method->addr); =0A=
 =0A=
 	if (!method->addr) {=0A=
-		g_warning ("Failed to load function %s from %s", import, scope);=0A=
+		mono_trace_warning (MONO_TRACE_DLLIMPORT, "Failed to load function %s =
from %s", import, scope);=0A=
 		return NULL;=0A=
 	}=0A=
 	return method->addr;=0A=
Index: mono/metadata/object.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/metadata/object.h,v=0A=
retrieving revision 1.87=0A=
diff -u -r1.87 object.h=0A=
--- mono/metadata/object.h	21 Feb 2003 22:42:16 -0000	1.87=0A=
+++ mono/metadata/object.h	2 Mar 2003 16:07:17 -0000=0A=
@@ -368,13 +368,13 @@=0A=
 mono_load_remote_field (MonoObject *this_obj, MonoClass *klass, =
MonoClassField *field, gpointer *res);=0A=
 =0A=
 MonoObject *=0A=
-mono_load_remote_field_new (MonoObject *this, MonoClass *klass, =
MonoClassField *field);=0A=
+mono_load_remote_field_new (MonoObject *this_obj, MonoClass *klass, =
MonoClassField *field);=0A=
 =0A=
 void=0A=
 mono_store_remote_field (MonoObject *this_obj, MonoClass *klass, =
MonoClassField *field, gpointer val);=0A=
 =0A=
 void=0A=
-mono_store_remote_field_new (MonoObject *this, MonoClass *klass, =
MonoClassField *field, MonoObject *arg);=0A=
+mono_store_remote_field_new (MonoObject *this_obj, MonoClass *klass, =
MonoClassField *field, MonoObject *arg);=0A=
 =0A=
 void=0A=
 mono_method_return_message_restore (MonoMethod *method, gpointer =
*params, MonoArray *out_args);=0A=
Index: mono/metadata/threads.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/metadata/threads.h,v=0A=
retrieving revision 1.29=0A=
diff -u -r1.29 threads.h=0A=
--- mono/metadata/threads.h	21 Feb 2003 23:45:03 -0000	1.29=0A=
+++ mono/metadata/threads.h	2 Mar 2003 16:07:17 -0000=0A=
@@ -52,11 +52,11 @@=0A=
 				       gpointer arg);=0A=
 extern MonoThread *mono_thread_attach (MonoDomain *domain);=0A=
 =0A=
-extern HANDLE =
ves_icall_System_Threading_Thread_Thread_internal(MonoThread *this, =
MonoObject *start);=0A=
-extern void =
ves_icall_System_Threading_Thread_Thread_free_internal(MonoThread *this, =
HANDLE thread);=0A=
-extern void ves_icall_System_Threading_Thread_Start_internal(MonoThread =
*this, HANDLE thread);=0A=
+extern HANDLE =
ves_icall_System_Threading_Thread_Thread_internal(MonoThread *this_obj, =
MonoObject *start);=0A=
+extern void =
ves_icall_System_Threading_Thread_Thread_free_internal(MonoThread =
*this_obj, HANDLE thread);=0A=
+extern void ves_icall_System_Threading_Thread_Start_internal(MonoThread =
*this_obj, HANDLE thread);=0A=
 extern void ves_icall_System_Threading_Thread_Sleep_internal(int ms);=0A=
-extern gboolean =
ves_icall_System_Threading_Thread_Join_internal(MonoThread *this, int =
ms, HANDLE thread);=0A=
+extern gboolean =
ves_icall_System_Threading_Thread_Join_internal(MonoThread *this_obj, =
int ms, HANDLE thread);=0A=
 extern gint32 ves_icall_System_Threading_Thread_GetDomainID (void);=0A=
 extern void ves_icall_System_Threading_Thread_SlotHash_store(MonoObject =
*data);=0A=
 extern MonoObject =
*ves_icall_System_Threading_Thread_SlotHash_lookup(void);=0A=
@@ -69,7 +69,7 @@=0A=
 =0A=
 extern gboolean =
ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray =
*mono_handles, gint32 ms, gboolean exitContext);=0A=
 extern gint32 =
ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray =
*mono_handles, gint32 ms, gboolean exitContext);=0A=
-extern gboolean =
ves_icall_System_Threading_WaitHandle_WaitOne_internal(MonoObject *this, =
HANDLE handle, gint32 ms, gboolean exitContext);=0A=
+extern gboolean =
ves_icall_System_Threading_WaitHandle_WaitOne_internal(MonoObject =
*this_obj, HANDLE handle, gint32 ms, gboolean exitContext);=0A=
 =0A=
 extern gint32 =
ves_icall_System_Threading_Interlocked_Increment_Int(gint32 *location);=0A=
 extern gint64 =
ves_icall_System_Threading_Interlocked_Increment_Long(gint64 *location);=0A=
Index: mono/utils/Makefile.am=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mono/mono/utils/Makefile.am,v=0A=
retrieving revision 1.7=0A=
diff -u -r1.7 Makefile.am=0A=
--- mono/utils/Makefile.am	25 Jul 2002 12:02:04 -0000	1.7=0A=
+++ mono/utils/Makefile.am	2 Mar 2003 16:07:18 -0000=0A=
@@ -3,19 +3,21 @@=0A=
 INCLUDES =3D $(GLIB_CFLAGS) $(GMODULE_CFLAGS) -I$(top_srcdir)	=
-I$(top_srcdir)/mono =0A=
 =0A=
 libmonoutils_la_SOURCES =3D \=0A=
-	mono-hash.c	\=0A=
-	mono-md5.c	\=0A=
-	mono-sha1.c	\=0A=
+	mono-hash.c		\=0A=
+	mono-md5.c		\=0A=
+	mono-sha1.c		\=0A=
 	monobitset.c	\=0A=
-	strtod.h	\=0A=
-	strtod.c=0A=
+	strtod.h		\=0A=
+	strtod.c		\=0A=
+	mono-logger.c=0A=
 =0A=
 libmonoutilsincludedir =3D $(includedir)/mono/utils=0A=
 =0A=
 libmonoutilsinclude_HEADERS =3D \=0A=
 	monobitset.h	\=0A=
 	mono-digest.h	\=0A=
-	mono-hash.h=0A=
+	mono-hash.h		\=0A=
+	mono-logger.h=0A=
 =0A=
 EXTRA_DIST =3D ChangeLog=0A=
 =0A=

------=_NextPart_000_077F_01C2E0E3.7F869680
Content-Type: application/octet-stream;
	name="mono-logger.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="mono-logger.c"

#include <glib.h>=0A=
#include <string.h>=0A=
=0A=
#include "mono-logger.h"=0A=
=0A=
typedef struct {=0A=
	GLogLevelFlags	level;=0A=
	MonoTraceMask	mask;=0A=
} MonoLogLevelEntry;=0A=
=0A=
static GLogLevelFlags g_current_level	=3D G_LOG_LEVEL_INFO;=0A=
static MonoTraceMask g_current_mask		=3D MONO_TRACE_ALL;=0A=
=0A=
static const char	*g_mono_log_domain =3D "Mono";=0A=
static GQueue		*g_level_stack =3D NULL;=0A=
=0A=
/**=0A=
 * mono_trace_init:=0A=
 *=0A=
 * Initializes the mono tracer.=0A=
 */=0A=
void =0A=
mono_trace_init (void)=0A=
{=0A=
	if(g_level_stack !=3D NULL) {=0A=
		g_warning(G_GNUC_PRETTY_FUNCTION ": Init already called.");=0A=
	} else {=0A=
		g_level_stack =3D g_queue_new();=0A=
	}=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace_cleanup:=0A=
 *=0A=
 * Releases the mono tracer.=0A=
 */=0A=
void =0A=
mono_trace_cleanup (void)=0A=
{=0A=
	if(g_level_stack !=3D NULL) {=0A=
		while(!g_queue_is_empty (g_level_stack)) {=0A=
			g_free (g_queue_pop_head (g_level_stack));=0A=
		}=0A=
=0A=
		g_queue_free (g_level_stack);=0A=
		g_level_stack =3D NULL;=0A=
	}=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace:=0A=
 *=0A=
 *	@level: Verbose level of the specified message=0A=
 *	@mask: Type of the specified message=0A=
 *=0A=
 * Traces a new message, depending on the current logging level=0A=
 * and trace mask.=0A=
 */=0A=
void=0A=
mono_trace(GLogLevelFlags level, MonoTraceMask mask, const char *format, =
...) =0A=
{=0A=
	va_list ap;=0A=
=0A=
	if(level <=3D g_current_level && mask & g_current_mask) {=0A=
		va_start (ap, format);=0A=
		g_logv (g_mono_log_domain, level, format, ap);=0A=
		va_end (ap);=0A=
	}=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace_set:=0A=
 *=0A=
 *	@level: Verbose level to set=0A=
 *	@mask: Mask of visible message types.=0A=
 *=0A=
 * Sets the current logging level and mask. Every subsequent call to=0A=
 * mono_trace will check the visibility of a message against these=0A=
 * values.=0A=
 */=0A=
void =0A=
mono_trace_set (GLogLevelFlags level, MonoTraceMask mask)=0A=
{=0A=
	g_current_level =3D level;=0A=
	g_current_mask	=3D mask;=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace_set_level:=0A=
 *=0A=
 *	@level: Verbose level to set=0A=
 *=0A=
 * Sets the current logging level. Every subsequent call to=0A=
 * mono_trace will check the visibility of a message against this=0A=
 * value.=0A=
 */=0A=
void =0A=
mono_trace_set_level (GLogLevelFlags level)=0A=
{=0A=
	g_current_level =3D level;=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace_set_mask:=0A=
 *=0A=
 *	@mask: Mask of visible message types.=0A=
 *=0A=
 * Sets the current logging level. Every subsequent call to=0A=
 * mono_trace will check the visibility of a message against this=0A=
 * value.=0A=
 */=0A=
void =0A=
mono_trace_set_mask (MonoTraceMask mask)=0A=
{=0A=
	g_current_mask	=3D mask;=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace_push:=0A=
 *=0A=
 *	@level: Verbose level to set=0A=
 *	@mask: Mask of visible message types.=0A=
 *=0A=
 * Saves the current values of level and mask then calls mono_trace_set=0A=
 * with the specified new values.=0A=
 */=0A=
void =0A=
mono_trace_push (GLogLevelFlags level, MonoTraceMask mask)=0A=
{=0A=
	if(g_level_stack =3D=3D NULL) {=0A=
		g_error(G_GNUC_PRETTY_FUNCTION ": cannot use mono_trace_push without =
calling mono_trace_init first.");=0A=
	} else {=0A=
		MonoLogLevelEntry *entry =3D g_malloc(sizeof(MonoLogLevelEntry));=0A=
		entry->level	=3D g_current_level;=0A=
		entry->mask		=3D g_current_mask;=0A=
=0A=
        g_queue_push_head (g_level_stack, (gpointer)entry);=0A=
=0A=
		/* Set the new level and mask=0A=
		 */=0A=
		mono_trace_set (level, mask);=0A=
	}=0A=
}=0A=
=0A=
/**=0A=
 * mono_trace_pop:=0A=
 *=0A=
 * Restores level and mask values saved from a previous call to =
mono_trace_push.=0A=
 */=0A=
void =0A=
mono_trace_pop (void)=0A=
{=0A=
	if(g_level_stack =3D=3D NULL) {=0A=
		g_error(G_GNUC_PRETTY_FUNCTION ": cannot use mono_trace_pop without =
calling mono_trace_init first.");=0A=
	} else {=0A=
		if(!g_queue_is_empty (g_level_stack)) {=0A=
			MonoLogLevelEntry *entry =3D (MonoLogLevelEntry*)g_queue_pop_head =
(g_level_stack);=0A=
=0A=
			/*	Restore previous level and mask=0A=
			 */=0A=
			mono_trace_set (entry->level, entry->mask);=0A=
=0A=
			g_free (entry);=0A=
		}=0A=
	}=0A=
}=0A=

------=_NextPart_000_077F_01C2E0E3.7F869680
Content-Type: application/octet-stream;
	name="mono-logger.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="mono-logger.h"

#ifndef __MONO_LOGGER_H__=0A=
#define __MONO_LOGGER_H__=0A=
=0A=
#include <glib.h>=0A=
=0A=
#define mono_trace_error(...)	mono_trace(G_LOG_LEVEL_ERROR, \=0A=
											__VA_ARGS__)=0A=
#define mono_trace_warning(...) mono_trace(G_LOG_LEVEL_WARNING, \=0A=
											__VA_ARGS__)=0A=
#define mono_trace_message(...) mono_trace(G_LOG_LEVEL_MESSAGE, \=0A=
											__VA_ARGS__)=0A=
=0A=
typedef enum {=0A=
	MONO_TRACE_ASSEMBLY		=3D (1<<0),=0A=
	MONO_TRACE_TYPE			=3D (1<<1),=0A=
	MONO_TRACE_DLLIMPORT	=3D (1<<2),=0A=
=0A=
	MONO_TRACE_ALL			=3D   MONO_TRACE_ASSEMBLY |=0A=
								MONO_TRACE_TYPE |=0A=
								MONO_TRACE_DLLIMPORT,=0A=
} MonoTraceMask;=0A=
=0A=
void =0A=
mono_trace_init (void);=0A=
=0A=
void =0A=
mono_trace_cleanup (void);=0A=
=0A=
void =0A=
mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char =
*format, ...);=0A=
=0A=
void =0A=
mono_trace_set (GLogLevelFlags level, MonoTraceMask mask);=0A=
=0A=
void =0A=
mono_trace_set_level (GLogLevelFlags level);=0A=
=0A=
void =0A=
mono_trace_set_mask (MonoTraceMask mask);=0A=
=0A=
void =0A=
mono_trace_push (GLogLevelFlags level, MonoTraceMask mask);=0A=
=0A=
void =0A=
mono_trace_pop (void);=0A=
=0A=
=0A=
#endif=0A=

------=_NextPart_000_077F_01C2E0E3.7F869680--