mirror of
https://github.com/aaru-dps/Aaru.Console.git
synced 2025-12-16 19:24:32 +00:00
[Console] Use Spectre.Console to show exceptions in the CLI.
GUI still uses `ConsoleWindow`.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
// Copyright © 2011-2023 Natalia Portillo
|
// Copyright © 2011-2023 Natalia Portillo
|
||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Aaru.Console;
|
namespace Aaru.Console;
|
||||||
@@ -107,6 +108,12 @@ public delegate void DebugWriteHandler(string format, params object[] arg);
|
|||||||
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
/// <param name="arg">An array of objects to write using <paramref name="format" />.</param>
|
||||||
public delegate void DebugWithModuleWriteLineHandler(string module, string format, params object[] arg);
|
public delegate void DebugWithModuleWriteLineHandler(string module, string format, params object[] arg);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the exception to the debug output console.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ex">Exception.</param>
|
||||||
|
public delegate void WriteExceptionHandler(Exception ex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implements a console abstraction that defines four level of messages that can be routed to different consoles:
|
/// Implements a console abstraction that defines four level of messages that can be routed to different consoles:
|
||||||
/// standard, error, verbose and debug.
|
/// standard, error, verbose and debug.
|
||||||
@@ -141,6 +148,9 @@ public static class AaruConsole
|
|||||||
/// <summary>Event to receive writings to the debug output console.</summary>
|
/// <summary>Event to receive writings to the debug output console.</summary>
|
||||||
public static event DebugWriteHandler DebugWriteEvent;
|
public static event DebugWriteHandler DebugWriteEvent;
|
||||||
|
|
||||||
|
/// <summary>Event to receive exceptions to write to the debug output console.</summary>
|
||||||
|
public static event WriteExceptionHandler WriteExceptionEvent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
/// Writes the text representation of the specified array of objects, followed by the current line terminator, to
|
||||||
/// the standard output console using the specified format information.
|
/// the standard output console using the specified format information.
|
||||||
@@ -242,4 +252,11 @@ public static class AaruConsole
|
|||||||
/// <param name="value">The value to write.</param>
|
/// <param name="value">The value to write.</param>
|
||||||
public static void DebugWriteLine(string module, string value) =>
|
public static void DebugWriteLine(string module, string value) =>
|
||||||
DebugWriteLineEvent?.Invoke("{0}", "DEBUG (" + module + "): " + value);
|
DebugWriteLineEvent?.Invoke("{0}", "DEBUG (" + module + "): " + value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the exception to the debug output console.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ex">Exception.</param>
|
||||||
|
public static void WriteException(Exception ex) =>
|
||||||
|
WriteExceptionEvent?.Invoke(ex);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user