diff options
| author | Orry Verducci <orry@orryverducci.co.uk> | 2021-12-01 22:13:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-01 22:13:52 +0000 |
| commit | e446e9fde935ad5744500e6efaab8fcacf89b600 (patch) | |
| tree | 9012e91423660bf4bc9992f06cf26f53e826fb65 /MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs | |
| parent | 9abe9e7e54cc454667ba2128b5d321631b5ece51 (diff) | |
| parent | f6d8c19a7ac41c6c7c217d9e9ccbf98f78122327 (diff) | |
Merge branch 'master' into mbaff-interlace-detection
Diffstat (limited to 'MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs')
| -rw-r--r-- | MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs b/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs new file mode 100644 index 000000000..dea1c2f32 --- /dev/null +++ b/MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs @@ -0,0 +1,31 @@ +using System; +using System.IO; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.ClientEvent +{ + /// <inheritdoc /> + public class ClientEventLogger : IClientEventLogger + { + private readonly IServerApplicationPaths _applicationPaths; + + /// <summary> + /// Initializes a new instance of the <see cref="ClientEventLogger"/> class. + /// </summary> + /// <param name="applicationPaths">Instance of the <see cref="IServerApplicationPaths"/> interface.</param> + public ClientEventLogger(IServerApplicationPaths applicationPaths) + { + _applicationPaths = applicationPaths; + } + + /// <inheritdoc /> + public async Task<string> WriteDocumentAsync(string clientName, string clientVersion, Stream fileContents) + { + var fileName = $"upload_{clientName}_{clientVersion}_{DateTime.UtcNow:yyyyMMddHHmmss}_{Guid.NewGuid():N}.log"; + var logFilePath = Path.Combine(_applicationPaths.LogDirectoryPath, fileName); + await using var fileStream = new FileStream(logFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.None); + await fileContents.CopyToAsync(fileStream).ConfigureAwait(false); + return fileName; + } + } +} |
