Пример #1
0
        private void DebugStripMenuItem_Click(object sender, System.EventArgs e)
        {
            ToolStripMenuItem item  = sender as ToolStripMenuItem;
            DebuggerLogLevel  level = DebuggerLogLevel.Log;

            // Only one Toolstrip item checked at a time
            this.debugDiagnosticMenuItem.Checked = false;
            this.debugLogMenuItem.Checked        = false;
            this.debugEventMenuItem.Checked      = false;
            this.debugMsgMenuItem.Checked        = false;
            item.Checked = true;

            // Update the debugger
            if (item.Equals(debugDiagnosticMenuItem))
            {
                level = DebuggerLogLevel.Diagnostic;
            }
            if (item.Equals(debugEventMenuItem))
            {
                level = DebuggerLogLevel.Event;
            }
            if (item.Equals(debugMsgMenuItem))
            {
                level = DebuggerLogLevel.Message;
            }

            base.LogLevel = level;
        }
Пример #2
0
        /// <summary>
        /// Logs messages and errors to a log file using a <see cref="IFileLogger"/> instance.
        /// </summary>
        /// <param name="level">
        /// The <see cref="DebuggerLogLevel"/> of the message to be logged.
        /// </param>
        /// <param name="message"> The message to be logged. </param>
        /// <param name="overrideLevel">
        /// A boolean value indicating that the UIDebugger should log the
        /// message, regardless of <see cref="DebuggerLogLevel"/>.
        /// </param>
        /// <param name="suppressPopup">
        /// A boolean value indicating that the UIDebugger should ignore the
        /// <see cref="MessageBox"/> popup.
        /// </param>
        public void Log(DebuggerLogLevel level, string message, bool overrideLevel, bool suppressPopup)
        {
            base.Log(level, message, overrideLevel);

            // Show Alerts
            if (debugShowAlertsMenuItem.Checked && level >= _alertLevel)
            {
                if (!suppressPopup)
                {
                    ShowAlert(level, message);
                }
            }
        }
Пример #3
0
        private async static void Log(DebuggerLogLevel level, string message)
        {
            if (level >= MainPage.Settings.DebuggerLogLevel)
            {
                string sOutput = string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "[{0}] # {1:d} {2:HH:mm:ss}.{3:000} # {4}", level.GetToken(),
                    System.DateTime.Today, System.DateTime.Now,
                    System.DateTime.Now.Millisecond, message);

                await MainPage.Current.SendResponse(sOutput).ConfigureAwait(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Logs messages and errors to a log file using a <see cref="IFileLogger"/> instance.
        /// </summary>
        /// <param name="level">
        /// The <see cref="DebuggerLogLevel"/> of the message to be logged.
        /// </param>
        /// <param name="message"> The message to be logged. </param>
        /// <param name="overrideLevel">
        /// A boolean value indicating that the Debugger should log the
        /// message, regardless of <see cref="DebuggerLogLevel"/>.
        /// </param>
        public override void Log(DebuggerLogLevel level, string message, bool overrideLevel)
        {
            if (level >= this.LogLevel || overrideLevel)
            {
                string sOutput = string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    Galatea.Globalization.DiagnosticResources.Debugger_Log_Message_Format,
                    level.GetToken(), System.DateTime.Now, message);

                System.Diagnostics.Debug.WriteLine(sOutput);

                if (_fileLogger != null && _fileLogger.IsLogging)
                {
                    _fileLogger.Log(sOutput);
                }
            }
        }
Пример #5
0
        private void ShowAlert(DebuggerLogLevel level, string message)
        {
            MessageBoxIcon mbIcon;

            switch (level)
            {
            case DebuggerLogLevel.Critical:
                mbIcon = MessageBoxIcon.Stop;
                break;

            case DebuggerLogLevel.Error:
                mbIcon = MessageBoxIcon.Error;
                break;

            case DebuggerLogLevel.Warning:
                mbIcon = MessageBoxIcon.Warning;
                break;

            case DebuggerLogLevel.Message:
                mbIcon = MessageBoxIcon.Exclamation;
                break;

            default:
                mbIcon = MessageBoxIcon.Information;
                break;
            }

            #region Code Analysis

            MessageBoxOptions mbOptions;

            if (Container is ContainerControl && (Container as ContainerControl).RightToLeft == RightToLeft.Yes)
            {
                mbOptions = MessageBoxOptions.RightAlign & MessageBoxOptions.RtlReading;
            }
            else
            {
                mbOptions = MessageBoxOptions.DefaultDesktopOnly;
            }
            #endregion

            MessageBox.Show(message, Properties.Settings.Default.ApplicationTitle,
                            MessageBoxButtons.OK, mbIcon, MessageBoxDefaultButton.Button1, mbOptions);
        }
Пример #6
0
        /// <summary>
        /// Gets a string representing a <see cref="DebuggerLogLevel"/> value that
        /// is visible to the user.
        /// </summary>
        /// <param name="level">
        /// The <see cref="DebuggerLogLevel"/> to tokenize.
        /// </param>
        /// <returns>
        /// A string representing a <see cref="DebuggerLogLevel"/> value that is visible
        /// to the user.
        /// </returns>
        protected override string GetLogLevelToken(DebuggerLogLevel level)
        {
            switch (level)
            {
            case DebuggerLogLevel.Diagnostic: return(" ^^^ ");

            case DebuggerLogLevel.Log: return(" Log ");

            case DebuggerLogLevel.Event: return("Event");

            case DebuggerLogLevel.Message: return(" Msg ");

            case DebuggerLogLevel.Warning: return("Warn ");

            case DebuggerLogLevel.Error: return("Error");

            case DebuggerLogLevel.Critical: return("*ERR*");

            case DebuggerLogLevel.StackTrace: return("TRACE");

            default: throw new TeaArgumentException();
            }
        }
Пример #7
0
        /// <summary>
        /// Logs messages and errors to a log file using a <see cref="IFileLogger"/> instance.
        /// </summary>
        /// <param name="level">
        /// The <see cref="DebuggerLogLevel"/> of the message to be logged.
        /// </param>
        /// <param name="message"> The message to be logged. </param>
        /// <param name="overrideLevel">
        /// A boolean value indicating that the Debugger should log the
        /// message, regardless of <see cref="DebuggerLogLevel"/>.
        /// </param>
        public override void Log(DebuggerLogLevel level, string message, bool overrideLevel)
        {
            if (level >= this.LogLevel || overrideLevel)
            {
                string sOutput = string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    DiagnosticResources.Debugger_Log_Message_Format,
                    GetLogLevelToken(level), DateTime.Now, message);

                // Output to log file
                System.Diagnostics.Debug.WriteLine(sOutput);

                if (_fileLogger == null)
                {
                    return;
                }

                if (IsInitialized && _fileLogger.IsLogging)
                {
                    _fileLogger.Log(sOutput);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Converts a <see cref="DebuggerLogLevel"/> enum value into a text value
        /// for logging.
        /// </summary>
        /// <param name="value">
        /// The <see cref="DebuggerLogLevel"/> enum value to convert.
        /// </param>
        /// <returns>
        /// A tet value.
        /// </returns>
        public static string GetToken(this DebuggerLogLevel value)
        {
            switch (value)
            {
            case DebuggerLogLevel.Diagnostic: return(" ^^^ ");

            case DebuggerLogLevel.Log: return(" Log ");

            case DebuggerLogLevel.Event: return("Event");

            case DebuggerLogLevel.Message: return(" Msg ");

            case DebuggerLogLevel.Warning: return("Warn ");

            case DebuggerLogLevel.Error: return("Error");

            case DebuggerLogLevel.Critical: return("*ERR*");

            case DebuggerLogLevel.StackTrace: return("TRACE");

            default: throw new Galatea.TeaArgumentException();
            }
        }
Пример #9
0
 /// <summary>
 /// Logs messages and errors.
 /// </summary>
 /// <param name="level">
 /// The <see cref="DebuggerLogLevel"/> of the message to be logged.
 /// </param>
 /// <param name="message"> The message to be logged. </param>
 public override void Log(DebuggerLogLevel level, string message)
 {
     this.Log(level, message, false);
 }