using System;
namespace BepInEx.Logging
{
///
/// A generic, multi-purpose log source. Exposes simple API to manually emit logs.
///
public class ManualLogSource : ILogSource
{
///
public string SourceName { get; }
///
public event EventHandler LogEvent;
///
/// Creates a manual log source.
///
/// Name of the log source.
public ManualLogSource(string sourceName)
{
SourceName = sourceName;
}
///
/// Logs a message with the specified log level.
///
/// Log levels to attach to the message. Multiple can be used with bitwise ORing.
/// Data to log.
public void Log(LogLevel level, object data)
{
LogEvent?.Invoke(this, new LogEventArgs(data, level, this));
}
///
/// Logs a message with level.
///
/// Data to log.
public void LogFatal(object data) => Log(LogLevel.Fatal, data);
///
/// Logs a message with level.
///
/// Data to log.
public void LogError(object data) => Log(LogLevel.Error, data);
///
/// Logs a message with level.
///
/// Data to log.
public void LogWarning(object data) => Log(LogLevel.Warning, data);
///
/// Logs a message with level.
///
/// Data to log.
public void LogMessage(object data) => Log(LogLevel.Message, data);
///
/// Logs a message with level.
///
/// Data to log.
public void LogInfo(object data) => Log(LogLevel.Info, data);
///
/// Logs a message with level.
///
/// Data to log.
public void LogDebug(object data) => Log(LogLevel.Debug, data);
///
public void Dispose() { }
}
}