using System; using MediaBrowser.Model.ClientLog; using Microsoft.Extensions.Logging; namespace MediaBrowser.Controller.ClientEvent { /// public class ClientEventLogger : IClientEventLogger { private const string LogString = "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level}] [{ClientName}:{ClientVersion}]: UserId: {UserId} DeviceId: {DeviceId}{NewLine}{Message}"; private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// Instance of the interface. public ClientEventLogger(ILogger logger) { _logger = logger; } /// public void Log(ClientLogEvent clientLogEvent) { _logger.Log( LogLevel.Critical, LogString, clientLogEvent.Timestamp, clientLogEvent.Level.ToString(), clientLogEvent.ClientName, clientLogEvent.ClientVersion, clientLogEvent.UserId ?? Guid.Empty, clientLogEvent.DeviceId, Environment.NewLine, clientLogEvent.Message); } } }