diff options
| author | Brian J. Murrell <brian@interlinx.bc.ca> | 2021-11-29 17:53:26 -0500 |
|---|---|---|
| committer | Brian J. Murrell <brian@interlinx.bc.ca> | 2021-11-29 17:53:26 -0500 |
| commit | 757970bfc17b0eb1566b45fbe700dcb16423b190 (patch) | |
| tree | 63fbc171621f5ec7ae156f341d9b1df37643deac /MediaBrowser.Controller/ClientEvent/ClientEventLogger.cs | |
| parent | a3a4689af22693b535e80b98624831866fda2a61 (diff) | |
| parent | c677b4f6b7f7e874097aa2cee866d9ed1e574178 (diff) | |
Merge remote-tracking branch 'origin/master' into HEAD
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; + } + } +} |
