mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
40
brutal.logging/Brutal.Logging/LogSystem.cs
Normal file
40
brutal.logging/Brutal.Logging/LogSystem.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Brutal.Logging;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all logging exceptions
|
||||
/// </summary>
|
||||
public class LogException(string message) : Exception(message);
|
||||
|
||||
/// <summary>
|
||||
/// Exception thrown when the logging system is used before being initialized
|
||||
/// </summary>
|
||||
public class LogNotInitializedException()
|
||||
: LogException("Log not initialized. Call Log.Initialize before using the logging system.");
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public static class LogSystem
|
||||
{
|
||||
internal static ILoggerFactory? Factory;
|
||||
|
||||
/// <summary>
|
||||
/// Enable or Disable all logging completely
|
||||
/// </summary>
|
||||
public static bool IsEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize and enable the log system
|
||||
/// </summary>
|
||||
public static void Initialize(Action<ILoggingBuilder> builder)
|
||||
{
|
||||
IsEnabled = true;
|
||||
Factory = LoggerFactory.Create(builder);
|
||||
foreach (var (categoryName, category) in LogCategory.Categories)
|
||||
category.Logger = Factory.CreateLogger(categoryName);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue