diff options
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics/LogSwitch.cs')
-rw-r--r-- | src/mscorlib/src/System/Diagnostics/LogSwitch.cs | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs index 14f0f26d98..29d6a1d4e6 100644 --- a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs +++ b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs @@ -2,14 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System.Diagnostics { - using System; - using System.IO; - using System.Collections; - using System.Runtime.Versioning; - using System.Diagnostics.Contracts; - using System.Diagnostics.CodeAnalysis; - +using System; +using System.IO; +using System.Collections; +using System.Runtime.Versioning; +using System.Diagnostics.Contracts; +using System.Diagnostics.CodeAnalysis; + +namespace System.Diagnostics +{ [Serializable] internal class LogSwitch { @@ -18,17 +19,17 @@ namespace System.Diagnostics { // same in the EE code (debugdebugger.cpp/debugdebugger.h) internal String strName; internal String strDescription; - private LogSwitch ParentSwitch; + private LogSwitch ParentSwitch; internal volatile LoggingLevels iLevel; internal volatile LoggingLevels iOldLevel; - + // ! END WARNING ! - - - private LogSwitch () + + + private LogSwitch() { } - + // Constructs a LogSwitch. A LogSwitch is used to categorize log messages. // // All switches (except for the global LogSwitch) have a parent LogSwitch. @@ -36,27 +37,27 @@ namespace System.Diagnostics { public LogSwitch(String name, String description, LogSwitch parent) { if (name != null && name.Length == 0) - throw new ArgumentOutOfRangeException(nameof(Name), Environment.GetResourceString("Argument_StringZeroLength")); + throw new ArgumentOutOfRangeException(nameof(Name), SR.Argument_StringZeroLength); Contract.EndContractBlock(); if ((name != null) && (parent != null)) - { + { strName = name; strDescription = description; iLevel = LoggingLevels.ErrorLevel; iOldLevel = iLevel; ParentSwitch = parent; - - Log.m_Hashtable.Add (strName, this); - + + Log.m_Hashtable.Add(strName, this); + // Call into the EE to let it know about the creation of // this switch - Log.AddLogSwitch (this); + Log.AddLogSwitch(this); } else - throw new ArgumentNullException ((name==null ? nameof(name) : nameof(parent))); + throw new ArgumentNullException((name == null ? nameof(name) : nameof(parent))); } - + internal LogSwitch(String name, String description) { strName = name; @@ -65,39 +66,39 @@ namespace System.Diagnostics { iOldLevel = iLevel; ParentSwitch = null; - Log.m_Hashtable.Add (strName, this); - + Log.m_Hashtable.Add(strName, this); + // Call into the EE to let it know about the creation of // this switch - Log.AddLogSwitch (this); + Log.AddLogSwitch(this); } - - + + // Get property returns the name of the switch public virtual String Name { - get { return strName;} + get { return strName; } } - - + + // Property to Get/Set the level of log messages which are "on" for the switch. // - public virtual LoggingLevels MinimumLevel + public virtual LoggingLevels MinimumLevel { get { return iLevel; } - set - { - iLevel = value; + set + { + iLevel = value; iOldLevel = value; - String strParentName = ParentSwitch!=null ? ParentSwitch.Name : ""; + String strParentName = ParentSwitch != null ? ParentSwitch.Name : ""; if (Debugger.IsAttached) - Log.ModifyLogSwitch ((int)iLevel, strName, strParentName); - - Log.InvokeLogSwitchLevelHandlers (this, iLevel); + Log.ModifyLogSwitch((int)iLevel, strName, strParentName); + + Log.InvokeLogSwitchLevelHandlers(this, iLevel); } } - - + + // Checks if the given level is "on" for this switch or one of its parents. // public virtual bool CheckLevel(LoggingLevels level) @@ -105,22 +106,21 @@ namespace System.Diagnostics { if (iLevel > level) { // recurse through the list till parent is hit. - if (this.ParentSwitch == null) + if (ParentSwitch == null) return false; else - return this.ParentSwitch.CheckLevel (level); + return ParentSwitch.CheckLevel(level); } else return true; } - - + + // Returns a switch with the particular name, if any. Returns null if no // such switch exists. public static LogSwitch GetSwitch(String name) { return (LogSwitch)Log.m_Hashtable[name]; } - } } |