using Microsoft.Extensions.Logging;
namespace Brutal.Logging;
///
/// Base class for all logging exceptions
///
public class LogException(string message) : Exception(message);
///
/// Exception thrown when the logging system is used before being initialized
///
public class LogNotInitializedException()
: LogException("Log not initialized. Call Log.Initialize before using the logging system.");
///
/// Static class for handling logging functionality across the framework.
/// Provides methods for initializing, printing, and managing log messages
/// with different log levels, as well as interacting with external configurations.
///
public static class LogSystem
{
internal static ILoggerFactory? Factory;
///
/// Enable or Disable all logging completely
///
public static bool IsEnabled = false;
///
/// Initialize and enable the log system
///
public static void Initialize(Action builder)
{
IsEnabled = true;
Factory = LoggerFactory.Create(builder);
foreach (var (categoryName, category) in LogCategory.Categories)
category.Logger = Factory.CreateLogger(categoryName);
}
}