using System; namespace Best.HTTP.Shared.Logger { /// /// Provides an implementation of that writes log messages to the Unity Debug Console. /// public sealed class UnityOutput : ILogOutput { /// /// Gets a value indicating whether this log output accepts color codes. /// /// /// This property returns true when running in the Unity Editor and false otherwise. /// public bool AcceptColor { get; } = UnityEngine.Application.isEditor; /// /// Writes a log message to the Unity Debug Console based on the specified log level. /// /// The log level of the message. /// The log message to write. public void Write(Loglevels level, string logEntry) { switch (level) { case Loglevels.All: case Loglevels.Information: UnityEngine.Debug.Log(logEntry); break; case Loglevels.Warning: UnityEngine.Debug.LogWarning(logEntry); break; case Loglevels.Error: case Loglevels.Exception: UnityEngine.Debug.LogError(logEntry); break; } } /// /// This implementation does nothing. /// void ILogOutput.Flush() {} void IDisposable.Dispose() => GC.SuppressFinalize(this); } }