using System.Runtime.CompilerServices;
namespace OSHttpServer
{
///
/// Priority for log entries
///
///
public enum LogPrio
{
None,
///
/// Very detailed logs to be able to follow the flow of the program.
///
Trace,
///
/// Logs to help debug errors in the application
///
Debug,
///
/// Information to be able to keep track of state changes etc.
///
Info,
///
/// Something did not go as we expected, but it's no problem.
///
Warning,
///
/// Something that should not fail failed, but we can still keep
/// on going.
///
Error,
///
/// Something failed, and we cannot handle it properly.
///
Fatal
}
///
/// Interface used to write to log files.
///
public interface ILogWriter
{
///
/// Write an entry to the log file.
///
/// object that is writing to the log
/// importance of the log message
/// the message
void Write(object source, LogPrio priority, string message);
}
///
/// Default log writer, writes everything to null (nowhere).
///
///
public sealed class NullLogWriter : ILogWriter
{
///
/// The logging instance.
///
public static readonly NullLogWriter Instance = new();
///
/// Writes everything to null
///
/// object that wrote the log entry.
/// Importance of the log message
/// The message.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(object source, LogPrio prio, string message) {}
}
}