Exemplo n.º 1
0
 public static void Log(string switchName, string message)
 {
     if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
     {
         return;
     }
     if (!BCLDebug.m_registryChecked)
     {
         BCLDebug.CheckRegistry();
     }
     try
     {
         LogSwitch @switch = LogSwitch.GetSwitch(switchName);
         if (@switch == null)
         {
             return;
         }
         Log.Trace(@switch, message);
         Log.Trace(@switch, Environment.NewLine);
     }
     catch
     {
         Log.Trace("Exception thrown in logging." + Environment.NewLine);
         Log.Trace("Switch was: " + (switchName == null ? "<null>" : switchName) + Environment.NewLine);
         Log.Trace("Message was: " + (message == null ? "<null>" : message) + Environment.NewLine);
     }
 }
Exemplo n.º 2
0
        public static void Log(string switchName, LogLevel level, params object[] messages)
        {
            if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
            {
                return;
            }
            if (!BCLDebug.m_registryChecked)
            {
                BCLDebug.CheckRegistry();
            }
            LogSwitch logSwitch;

            if (!BCLDebug.CheckEnabled(switchName, level, out logSwitch))
            {
                return;
            }
            StringBuilder sb = StringBuilderCache.Acquire(16);

            for (int index = 0; index < messages.Length; ++index)
            {
                string str;
                try
                {
                    str = messages[index] != null ? messages[index].ToString() : "<null>";
                }
                catch
                {
                    str = "<unable to convert>";
                }
                sb.Append(str);
            }
            Log.LogMessage((LoggingLevels)level, logSwitch, StringBuilderCache.GetStringAndRelease(sb));
        }
Exemplo n.º 3
0
 internal static bool CorrectnessEnabled()
 {
     if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
     {
         return(false);
     }
     if (!BCLDebug.m_registryChecked)
     {
         BCLDebug.CheckRegistry();
     }
     return(BCLDebug.m_correctnessWarnings);
 }
Exemplo n.º 4
0
 public static void Log(string message)
 {
     if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
     {
         return;
     }
     if (!BCLDebug.m_registryChecked)
     {
         BCLDebug.CheckRegistry();
     }
     Log.Trace(message);
     Log.Trace(Environment.NewLine);
 }
        internal static bool CheckEnabled(string switchName)
        {
            if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
            {
                return(false);
            }
            if (!BCLDebug.m_registryChecked)
            {
                BCLDebug.CheckRegistry();
            }
            LogSwitch @switch = LogSwitch.GetSwitch(switchName);

            return(@switch != null && @switch.MinimumLevel <= LoggingLevels.TraceLevel0);
        }
Exemplo n.º 6
0
        public static void DumpStack(string switchName)
        {
            if (!BCLDebug.m_registryChecked)
            {
                BCLDebug.CheckRegistry();
            }
            LogSwitch logSwitch;

            if (!BCLDebug.CheckEnabled(switchName, LogLevel.Trace, out logSwitch))
            {
                return;
            }
            StackTrace stackTrace = new StackTrace();

            Log.LogMessage(LoggingLevels.TraceLevel0, logSwitch, stackTrace.ToString());
        }
 internal static void Perf(bool expr, string msg)
 {
     if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
     {
         return;
     }
     if (!BCLDebug.m_registryChecked)
     {
         BCLDebug.CheckRegistry();
     }
     if (!BCLDebug.m_perfWarnings)
     {
         return;
     }
     System.Diagnostics.Assert.Check(expr, "BCL Perf Warning: Your perf may be less than perfect because...", msg);
 }
        public static void Log(string switchName, LogLevel level, params object[] messages)
        {
            if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize())
            {
                return;
            }
            if (!BCLDebug.m_registryChecked)
            {
                BCLDebug.CheckRegistry();
            }
            LogSwitch logswitch;

            if (!BCLDebug.CheckEnabled(switchName, level, out logswitch))
            {
                return;
            }
            StringBuilder stringBuilder = StringBuilderCache.Acquire(16);

            for (int i = 0; i < messages.Length; i++)
            {
                string value;
                try
                {
                    if (messages[i] == null)
                    {
                        value = "<null>";
                    }
                    else
                    {
                        value = messages[i].ToString();
                    }
                }
                catch
                {
                    value = "<unable to convert>";
                }
                stringBuilder.Append(value);
            }
            System.Diagnostics.Log.LogMessage((LoggingLevels)level, logswitch, StringBuilderCache.GetStringAndRelease(stringBuilder));
        }