Avoid unnecessary allocation on indexer access
[mono.git] / mcs / class / System / System.Diagnostics / DefaultTraceListener.cs
index 06e0473a4dc1b11f627d8c0370c4327ed91441f8..7a1e541ad9bfece3dcd9254c73408a40e1b614bf 100644 (file)
@@ -57,15 +57,19 @@ namespace System.Diagnostics {
                        // messages.  On Win32 platforms (OnWin32 = true), we use the
                        // `OutputDebugString' api.
                        //
-                       // On Linux platforms, we use MONO_TRACE to figure things out.  See the
-                       // API documentation for more information on MONO_TRACE.
+                       // On Linux platforms, we use MONO_TRACE_LISTENER to figure things out.  See the
+                       // API documentation for more information on MONO_TRACE_LISTENER.
                        OnWin32 = (Path.DirectorySeparatorChar == '\\');
 
                        if (!OnWin32) {
+#if TARGET_JVM
+                               string trace = java.lang.System.getProperty("MONO_TRACE");
+#else
                                // If we're running on Unix, we don't have OutputDebugString.
-                               // Instead, send output to...wherever the MONO_TRACE environment
+                               // Instead, send output to...wherever the MONO_TRACE_LISTENER environment
                                // variables says to.
-                               String trace = Environment.GetEnvironmentVariable("MONO_TRACE");
+                               String trace = Environment.GetEnvironmentVariable("MONO_TRACE_LISTENER");
+#endif
 
                                if (trace != null) {
                                        string file = null;
@@ -102,16 +106,16 @@ namespace System.Diagnostics {
                /**
                 * Get the prefix for the specified variable.
                 *
-                * "Prefixes" are used in the MONO_TRACE variable, and specify text that
+                * "Prefixes" are used in the MONO_TRACE_LISTENER variable, and specify text that
                 * should precede each message printed to the console.  The prefix is
                 * appended to the console location with a colon (':') separating them.
-                * For example, if MONO_TRACE is "Console.Out:** my prefix", the prefix is
+                * For example, if MONO_TRACE_LISTENER is "Console.Out:** my prefix", the prefix is
                 * "** my prefix".
                 *
                 * Everything after the colon, if the colon is present, is used as the
                 * prefix.
                 *
-                * @param       var             The current MONO_TRACE variable
+                * @param       var             The current MONO_TRACE_LISTENER variable
                 * @param       target  The name of the output location, e.g. "Console.Out"
                 */
                private static string GetPrefix (string var, string target)
@@ -158,6 +162,10 @@ namespace System.Diagnostics {
                        WriteLine (new StackTrace().ToString());
                }
 
+#if TARGET_JVM
+               private void WriteDebugString (string message)
+               {
+#else
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern static void WriteWindowsDebugString (string message);
 
@@ -166,6 +174,7 @@ namespace System.Diagnostics {
                        if (OnWin32)
                                WriteWindowsDebugString (message);
                        else
+#endif
                                WriteMonoTrace (message);
                }