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); } }
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)); }
internal static bool CorrectnessEnabled() { if (AppDomain.CurrentDomain.IsUnloadingForcedFinalize()) { return(false); } if (!BCLDebug.m_registryChecked) { BCLDebug.CheckRegistry(); } return(BCLDebug.m_correctnessWarnings); }
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); }
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)); }