[Mono-list] Diagnostic Messages

Lawrence Pit loz@cable.a2000.nl
Sun, 26 May 2002 21:03:13 +0300

Hi Jonathan,

> Linux/Unix, as far as I can tell, has no equivalent to
> `OutputDebugString'.  The console must be used instead (until someone
> tells me a better way to do it).

I'm not really familiar with Linux, but google tells me it has a syslog
(which they got from BSD). Regardless, if a system doesn't have something
similar to OutputDebugString I see no problem in simply sending the output
to /dev/null by default.

> So I have a problem: I want to leave trace code in the program, but I
> don't want the user to see it by default.
> If I want to see debug messages:
> $ mono --diagnostics=debug
> ** Mono-Debug: Debug Message
> Console Message
> The point I'm attempting to demonstrate is that this isn't a compiler
> issue, this is a runtime issue.  Trace and debug messages need to be
> sent somewhere in order to be seen (and thus useful), but we don't want
> them to be seen all the time, as it isn't appropriate.

The point I was trying to make is that it should not be a runtime issue, but
a compile time issue. Read the remarks in the documentation for
ConditionalAttribute, the compiler should ignore calls to Debug and Trace
methods unless a compilation variable is defined.

Certainly for debugging no switch should exist for mono. That would be a bit
of a shame, as the consequence would be that all debugging statements are in
the compiled code regardless of how it's compiled, therefor impacting
performance and code size of production software.

Tracing is somewhat different as you MIGHT want to enable that (temporarily)
in a production environment. Tracing is however usually controlled through
the application configuration file as it's not simply a matter of switching
tracing on or off when you startup a program, instead you can switch tracing
on for an ASP.NET application and off for another while both are running in
the same mono runtime instance. Also, via the app configuration file you can
configure more than just the property values on/off, but also things like
indent level, the trace switches that should be used, etc.