예제 #1
0
        /// ****************************************************************
        ///   public Write [static]
        /// ----------------------------------------------------------------
        ///   <summary>
        ///     Writes a message to the debugging logs.
        ///   </summary>
        /// ----------------------------------------------------------------
        ///   <param name="severity">
        ///     The Severity type.
        ///   </param>
        ///
        ///   <param name="category">
        ///     The category type.
        ///   </param>
        ///
        ///   <param name="message">
        ///     The message to log.
        ///   </param>
        /// ----------------------------------------------------------------
        ///   <remarks>
        ///     Debugging information is logged to the debugger, log file,
        ///     and event log depending on the level of the following
        ///     configuration settings:
        ///
        ///			Debug.DebuggerLevel
        ///			Debug.EventLogLevel
        ///			Debug.FileLogLevel
        ///
        ///		Where the trace level is the highest severity to log:
        ///			0 = none
        ///			1 = errors
        ///			2 = warnings
        ///			3 = failure audit messages
        ///			4 = success audit messages
        ///			5 = information messages
        ///			6 = all (verbose)
        ///   </remarks>
        /// ****************************************************************
        ///
        public static void Write(SeverityType severity, CategoryType category, string message)
        {
            //
            // Write to the debugger if the level setting is high enough.
            //
            if ((int)severity <= debuggerLevel.GetInt())
            {
                WriteDebugger(severity, category, message);
            }

            //
            // Write to the event log if the level setting is high enough.
            //
            if ((int)severity <= eventLogLevel.GetInt())
            {
                WriteEventLog(severity, category, OperatorMessageType.None, message);
            }

            //
            // Write to the file log if the level setting is high enough.
            //
            if ((int)severity <= fileLogLevel.GetInt())
            {
                WriteFileLog(severity, category, message);
            }
        }
예제 #2
0
        /// ****************************************************************
        ///   private FileLogLevel_OnChange [static]
        /// ----------------------------------------------------------------
        ///   <summary>
        ///     Handler for file log level configuration change events.
        ///   </summary>
        /// ****************************************************************
        ///
        private static void FileLogLevel_OnChange()
        {
            try
            {
                SeverityType newSeverity = ( SeverityType )fileLogLevel.GetInt();

                //
                // If logging is turned off, release our handle to the log file.
                //
                if (SeverityType.None == newSeverity)
                {
                    ReleaseLogFile();
                }
            }
            catch
            {
                //
                // We should never get any exceptions from this, but eat them if we do.  We don't want to
                // put our file logging in an inconsistent state.
                //
            }
        }
예제 #3
0
        /// ****************************************************************
        ///   public OperatorMessage [static]
        /// ----------------------------------------------------------------
        ///   <summary>
        ///		Writes an operator message to the event log.
        ///   </summary>
        /// ----------------------------------------------------------------
        ///   <param name="severity">
        ///     The severity of the message.
        ///   </param>
        ///
        ///   <param name="category">
        ///     The category of the message.
        ///   </param>
        ///
        ///   <param name="messageId">
        ///		Operator message type.
        ///   </param>
        ///
        ///   <param name="message">
        ///     Message to write to the event log.
        ///   </param>
        /// ****************************************************************
        ///
        public static void OperatorMessage(SeverityType severity, CategoryType category, OperatorMessageType messageId, string message)
        {
            try
            {
                //
                // Store the entry in the event log as an error.
                //
                WriteEventLog(
                    severity,
                    category,
                    messageId,
                    message);

                //
                // Also write this as a warning level message to any debug message
                // listeners (other than event log, since we already logged this
                // message there).
                //
                if ((int)severity <= debuggerLevel.GetInt())
                {
                    WriteDebugger(
                        severity,
                        category,
                        "Operator message [" + messageId.ToString() + "]: " + message);
                }

                if ((int)severity <= fileLogLevel.GetInt())
                {
                    WriteFileLog(
                        severity,
                        category,
                        "Operator message [" + messageId.ToString() + "]: " + message);
                }
            }
            catch (Exception)
            {
            }
        }