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; }
/// <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); } } }
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); } }
/// <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); } } }
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); }
/// <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(); } }
/// <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); } } }
/// <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(); } }
/// <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); }