Skip to content

Commit

Permalink
chore: Log experimental feature
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Jan 20, 2024
1 parent 18ac11e commit bafb41b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Testcontainers/Containers/DockerContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ protected override async Task UnsafeCreateAsync(CancellationToken ct = default)

if (_configuration.Reuse.HasValue && _configuration.Reuse.Value)
{
Logger.ReusableExperimentalFeature();

var filters = new FilterByReuseHash(_configuration);

var reusableContainers = await _client.Container.GetAllAsync(filters, ct)
Expand Down
8 changes: 8 additions & 0 deletions src/Testcontainers/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ internal static class Logging
private static readonly Action<ILogger, string, Exception> _DockerRegistryCredentialFound
= LoggerMessage.Define<string>(LogLevel.Information, default, "Docker registry credential {DockerRegistry} found");

private static readonly Action<ILogger, Exception> _ReusableExperimentalFeature
= LoggerMessage.Define(LogLevel.Warning, default, "Reuse is an experimental feature. For more information, visit: https://dotnet.testcontainers.org/api/resource_reuse/");

private static readonly Action<ILogger, Exception> _ReusableResourceFound
= LoggerMessage.Define(LogLevel.Information, default, "Reusable resource found");

Expand Down Expand Up @@ -261,6 +264,11 @@ public static void DockerRegistryCredentialFound(this ILogger logger, string doc
_DockerRegistryCredentialFound(logger, dockerRegistry, null);
}

public static void ReusableExperimentalFeature(this ILogger logger)
{
_ReusableExperimentalFeature(logger, null);
}

public static void ReusableResourceFound(this ILogger logger)
{
_ReusableResourceFound(logger, null);
Expand Down
2 changes: 2 additions & 0 deletions src/Testcontainers/Networks/DockerNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ protected override async Task UnsafeCreateAsync(CancellationToken ct = default)

if (_configuration.Reuse.HasValue && _configuration.Reuse.Value)
{
_logger.ReusableExperimentalFeature();

var filters = new FilterByReuseHash(_configuration);

var reusableNetworks = await _client.Network.GetAllAsync(filters, ct)
Expand Down
2 changes: 2 additions & 0 deletions src/Testcontainers/Volumes/DockerVolume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ protected override async Task UnsafeCreateAsync(CancellationToken ct = default)

if (_configuration.Reuse.HasValue && _configuration.Reuse.Value)
{
_logger.ReusableExperimentalFeature();

var filters = new FilterByReuseHash(_configuration);

var reusableVolumes = await _client.Volume.GetAllAsync(filters, ct)
Expand Down

0 comments on commit bafb41b

Please sign in to comment.