summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Diagnostics/log.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Diagnostics/log.cs')
-rw-r--r--src/mscorlib/src/System/Diagnostics/log.cs80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/mscorlib/src/System/Diagnostics/log.cs b/src/mscorlib/src/System/Diagnostics/log.cs
index d297b8fa08..b62ea493e7 100644
--- a/src/mscorlib/src/System/Diagnostics/log.cs
+++ b/src/mscorlib/src/System/Diagnostics/log.cs
@@ -2,7 +2,8 @@
// 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 {
+namespace System.Diagnostics
+{
using System.Runtime.Remoting;
using System;
using System.IO;
@@ -12,19 +13,19 @@ namespace System.Diagnostics {
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;
-
-
- // LogSwitchLevelHandlers are triggered when the level of a LogSwitch is modified
- // NOTE: These are NOT triggered when the log switch setting is changed from the
- // attached debugger.
- //
+
+ using Console = Internal.Console;
+
+ // LogSwitchLevelHandlers are triggered when the level of a LogSwitch is modified
+ // NOTE: These are NOT triggered when the log switch setting is changed from the
+ // attached debugger.
+ //
[Serializable]
internal delegate void LogSwitchLevelHandler(LogSwitch ls, LoggingLevels newLevel);
-
-
+
+
internal static class Log
{
-
// Switches allow relatively fine level control of which messages are
// actually shown. Normally most debugging messages are not shown - the
// user will typically enable those which are relevant to what is being
@@ -36,13 +37,13 @@ namespace System.Diagnostics {
// desired events are actually reported to the debugger.
internal static Hashtable m_Hashtable;
private static volatile bool m_fConsoleDeviceEnabled;
- private static volatile LogSwitchLevelHandler _LogSwitchLevelHandler;
+ private static volatile LogSwitchLevelHandler _LogSwitchLevelHandler;
private static Object locker;
-
+
// Constant representing the global switch
public static readonly LogSwitch GlobalSwitch;
-
-
+
+
static Log()
{
m_Hashtable = new Hashtable();
@@ -51,21 +52,21 @@ namespace System.Diagnostics {
//iNumOfMsgHandlers = 0;
//iMsgHandlerArraySize = 0;
locker = new Object();
-
+
// allocate the GlobalSwitch object
- GlobalSwitch = new LogSwitch ("Global", "Global Switch for this log");
-
+ GlobalSwitch = new LogSwitch("Global", "Global Switch for this log");
+
GlobalSwitch.MinimumLevel = LoggingLevels.ErrorLevel;
}
-
- internal static void InvokeLogSwitchLevelHandlers (LogSwitch ls, LoggingLevels newLevel)
+
+ internal static void InvokeLogSwitchLevelHandlers(LogSwitch ls, LoggingLevels newLevel)
{
LogSwitchLevelHandler handler = _LogSwitchLevelHandler;
if (handler != null)
handler(ls, newLevel);
}
-
-
+
+
// Property to Enable/Disable ConsoleDevice. Enabling the console device
// adds the console device as a log output, causing any
// log messages which make it through filters to be written to the
@@ -76,7 +77,7 @@ namespace System.Diagnostics {
get { return m_fConsoleDeviceEnabled; }
set { m_fConsoleDeviceEnabled = value; }
}
-
+
// Generates a log message. If its switch (or a parent switch) allows the
// level for the message, it is "broadcast" to all of the log
// devices.
@@ -84,28 +85,28 @@ namespace System.Diagnostics {
public static void LogMessage(LoggingLevels level, LogSwitch logswitch, String message)
{
if (logswitch == null)
- throw new ArgumentNullException ("LogSwitch");
-
+ throw new ArgumentNullException("LogSwitch");
+
if (level < 0)
- throw new ArgumentOutOfRangeException(nameof(level), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
+ throw new ArgumentOutOfRangeException(nameof(level), SR.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
-
+
// Is logging for this level for this switch enabled?
- if (logswitch.CheckLevel (level) == true)
+ if (logswitch.CheckLevel(level) == true)
{
// Send message for logging
-
+
// first send it to the debugger
- Debugger.Log ((int) level, logswitch.strName, message);
-
+ Debugger.Log((int)level, logswitch.strName, message);
+
// Send to the console device
if (m_fConsoleDeviceEnabled)
{
- Console.Write(message);
- }
+ Console.Write(message);
+ }
}
}
-
+
/*
* Following are convenience entry points; all go through Log()
* Note that the (Switch switch, String message) variations
@@ -113,20 +114,19 @@ namespace System.Diagnostics {
*/
public static void Trace(LogSwitch logswitch, String message)
{
- LogMessage (LoggingLevels.TraceLevel0, logswitch, message);
+ LogMessage(LoggingLevels.TraceLevel0, logswitch, message);
}
-
+
public static void Trace(String message)
{
- LogMessage (LoggingLevels.TraceLevel0, GlobalSwitch, message);
+ LogMessage(LoggingLevels.TraceLevel0, GlobalSwitch, message);
}
-
-
+
+
// Native method to inform the EE about the creation of a new LogSwitch
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void AddLogSwitch(LogSwitch logSwitch);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern void ModifyLogSwitch (int iNewLevel, String strSwitchName, String strParentName);
+ internal static extern void ModifyLogSwitch(int iNewLevel, String strSwitchName, String strParentName);
}
-
}