// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : AaruLogging.cs // Author(s) : Natalia Portillo // // Component : Console. // // --[ Description ] ---------------------------------------------------------- // // Handlers for normal, verbose and debug consoles. // // --[ License ] -------------------------------------------------------------- // // This library is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 2.1 of the // License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, see . // // ---------------------------------------------------------------------------- // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ using System; using System.Diagnostics.CodeAnalysis; namespace Aaru.Logging; /// /// Implements a console abstraction that defines four level of messages that can be routed to different consoles: /// standard, error, verbose and debug. /// [SuppressMessage("ReSharper", "UnusedMember.Global")] public static class AaruLogging { /// Event to receive writings to the standard output console that should be followed by a line termination. public static event WriteLineDelegate WriteLineEvent; /// Event to receive writings to the error output console that should be followed by a line termination. public static event ErrorDelegate ErrorEvent; /// Event to receive writings to the verbose output console that should be followed by a line termination. public static event VerboseDelegate VerboseEvent; /// Event to receive line terminations to the debug output console. public static event DebugDelegate DebugEvent; /// Event to receive writings to the standard output console. public static event WriteDelegate WriteEvent; /// Event to receive exceptions to write to the debug output console. public static event ExceptionDelegate WriteExceptionEvent; /// Event to receive writings to the informational output console that should be followed by a line termination. public static event InformationDelegate InformationEvent; /// /// 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. /// /// A composite format string. /// An array of objects to write using . public static void WriteLine(string format, params object[] arg) => WriteLineEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to /// the error output console using the specified format information. /// /// A composite format string. /// An array of objects to write using . public static void Error(string format, params object[] arg) => ErrorEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to /// the verbose output console using the specified format information. /// /// A composite format string. /// An array of objects to write using . public static void Verbose(string format, params object[] arg) => VerboseEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to /// the verbose output console using the specified format information. /// /// A composite format string. /// An array of objects to write using . public static void Information(string format, params object[] arg) => InformationEvent?.Invoke(format, arg); /// /// Writes the text representation of the specified array of objects, followed by the current line terminator, to /// the debug output console using the specified format information. /// /// Description of the module writing to the debug console /// A composite format string. /// An array of objects to write using . public static void Debug(string module, string format, params object[] arg) => DebugEvent?.Invoke(module, format, arg); /// Writes the current line terminator to the standard output console. public static void WriteLine() => WriteLineEvent?.Invoke("", null); /// /// Writes the text representation of the specified array of objects to the standard output console using the /// specified format information. /// /// A composite format string. /// An array of objects to write using . public static void Write(string format, params object[] arg) => WriteEvent?.Invoke(format, arg); /// /// Writes the exception to the debug output console. /// /// Exception. public static void Exception(Exception ex, string message, params object[] arg) => WriteExceptionEvent?.Invoke(ex, message, arg); }