Skip to content

Commit

Permalink
Remove temporary logging from Crypter.Common.Client
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Edwards committed Dec 31, 2024
1 parent 9cdc7fa commit 4b7fa60
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
4 changes: 0 additions & 4 deletions Crypter.Common.Client/Crypter.Common.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@
<ProjectReference Include="..\Crypter.Crypto.Common\Crypter.Crypto.Common.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>

</Project>
12 changes: 2 additions & 10 deletions Crypter.Common.Client/Transfer/Handlers/UploadFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ public class UploadFileHandler : UploadHandler
private long _fileSize;
private string? _fileContentType;
private bool _transferInfoSet;
private readonly ILogger<UploadFileHandler> _logger;

public UploadFileHandler(ICrypterApiClient crypterApiClient, ICryptoProvider cryptoProvider, ClientTransferSettings clientTransferSettings, ILogger<UploadFileHandler> logger)
public UploadFileHandler(ICrypterApiClient crypterApiClient, ICryptoProvider cryptoProvider, ClientTransferSettings clientTransferSettings)
: base(crypterApiClient, cryptoProvider, clientTransferSettings)
{
_logger = logger;
}
{ }

internal void SetTransferInfo(Func<Stream> fileStreamOpener, string fileName, long fileSize, string fileContentType, int expirationHours)
{
Expand Down Expand Up @@ -195,14 +192,9 @@ async IAsyncEnumerable<Func<MemoryStream>> SplitEncryptionStreamAsync(Encryption
}

double factor = ClientTransferSettings.TargetMultipartUploadMilliseconds / loopStopwatch.Elapsed.TotalMilliseconds;
_logger.LogWarning("Factor: {factor}, TargetMultipartUploadMilliseconds: {target}, ElapsedMilliseconds: {elapsed}", factor, ClientTransferSettings.TargetMultipartUploadMilliseconds, loopStopwatch.Elapsed.TotalMilliseconds);

int optimalBlocksPerRequest = Convert.ToInt32(blocksPerRequest * factor);
_logger.LogWarning("Optimal blocks per request: {optimalValue}", optimalBlocksPerRequest);

int lowerBound = Math.Max(ClientTransferSettings.InitialMultipartReadBlocks, optimalBlocksPerRequest);
blocksPerRequest = Math.Min(ClientTransferSettings.MaximumMultipartReadBlocks, lowerBound);
_logger.LogWarning("Blocks per next request: {blocks}", blocksPerRequest);
} while (!endOfStream);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
using Crypter.Crypto.Common;
using Crypter.Crypto.Common.StreamEncryption;
using EasyMonads;
using Microsoft.Extensions.Logging;

namespace Crypter.Common.Client.Transfer.Handlers;

Expand All @@ -46,13 +45,10 @@ public class UploadMessageHandler : UploadHandler
private string? _messageSubject;
private int _messageSize;
private bool _transferInfoSet;
private readonly ILogger<UploadMessageHandler> _logger;

public UploadMessageHandler(ICrypterApiClient crypterApiClient, ICryptoProvider cryptoProvider, ClientTransferSettings clientTransferSettings, ILogger<UploadMessageHandler> logger)
public UploadMessageHandler(ICrypterApiClient crypterApiClient, ICryptoProvider cryptoProvider, ClientTransferSettings clientTransferSettings)
: base(crypterApiClient, cryptoProvider, clientTransferSettings)
{
_logger = logger;
}
{ }

internal void SetTransferInfo(string messageSubject, string messageBody, int expirationHours)
{
Expand Down
9 changes: 3 additions & 6 deletions Crypter.Common.Client/Transfer/TransferHandlerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
using Crypter.Common.Client.Transfer.Models;
using Crypter.Common.Enums;
using Crypter.Crypto.Common;
using Microsoft.Extensions.Logging;

namespace Crypter.Common.Client.Transfer;

Expand All @@ -42,28 +41,26 @@ public class TransferHandlerFactory
private readonly ICryptoProvider _cryptoProvider;
private readonly IUserSessionService _userSessionService;
private readonly ClientTransferSettings _clientTransferSettings;
private readonly ILoggerFactory _loggerFactory;

public TransferHandlerFactory(ICrypterApiClient crypterApiClient, ICryptoProvider cryptoProvider,
IUserSessionService userSessionService, ClientTransferSettings clientTransferSettings, ILoggerFactory loggerFactory)
IUserSessionService userSessionService, ClientTransferSettings clientTransferSettings)
{
_crypterApiClient = crypterApiClient;
_cryptoProvider = cryptoProvider;
_userSessionService = userSessionService;
_clientTransferSettings = clientTransferSettings;
_loggerFactory = loggerFactory;
}

public UploadFileHandler CreateUploadFileHandler(Func<Stream> fileStreamOpener, string fileName, long fileSize, string fileContentType, int expirationHours)
{
UploadFileHandler handler = new UploadFileHandler(_crypterApiClient, _cryptoProvider, _clientTransferSettings, _loggerFactory.CreateLogger<UploadFileHandler>());
UploadFileHandler handler = new UploadFileHandler(_crypterApiClient, _cryptoProvider, _clientTransferSettings);
handler.SetTransferInfo(fileStreamOpener, fileName, fileSize, fileContentType, expirationHours);
return handler;
}

public UploadMessageHandler CreateUploadMessageHandler(string messageSubject, string messageBody, int expirationHours)
{
UploadMessageHandler handler = new UploadMessageHandler(_crypterApiClient, _cryptoProvider, _clientTransferSettings, _loggerFactory.CreateLogger<UploadMessageHandler>());
UploadMessageHandler handler = new UploadMessageHandler(_crypterApiClient, _cryptoProvider, _clientTransferSettings);
handler.SetTransferInfo(messageSubject, messageBody, expirationHours);
return handler;
}
Expand Down

0 comments on commit 4b7fa60

Please sign in to comment.