Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Log Docker image build progress messages #839

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma warning disable SA1402
#pragma warning disable SA1403
#pragma warning disable SA1402, SA1403

namespace DotNet.Testcontainers
{
Expand Down Expand Up @@ -99,5 +98,4 @@ public sealed class TestcontainersBuilder<TContainerEntity> : ContainerBuilder<T
}
}

#pragma warning restore SA1402
#pragma warning restore SA1403
#pragma warning restore SA1402, SA1403
10 changes: 10 additions & 0 deletions src/Testcontainers/Clients/TraceProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ public void Report(JSONMessage value)
{
#pragma warning disable CA1848, CA2254

if (!string.IsNullOrWhiteSpace(value.Status))
{
this.logger.LogTrace(value.Status);
}

if (!string.IsNullOrWhiteSpace(value.Stream))
{
this.logger.LogTrace(value.Stream);
}

if (!string.IsNullOrWhiteSpace(value.ProgressMessage))
{
this.logger.LogTrace(value.ProgressMessage);
Expand Down
7 changes: 4 additions & 3 deletions src/Testcontainers/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ namespace DotNet.Testcontainers
{
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
using DotNet.Testcontainers.Images;
using Microsoft.Extensions.Logging;

[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309", MessageId = "Field names should not begin with underscore", Justification = "Do not apply rule for delegate fields.")]
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Do not apply rule for delegate fields.")]
internal static class Logging
{
#pragma warning disable InconsistentNaming, SA1309

private static readonly Action<ILogger, Regex, Exception> _IgnorePatternAdded
= LoggerMessage.Define<Regex>(LogLevel.Information, default, "Pattern {IgnorePattern} added to the regex cache");

Expand Down Expand Up @@ -80,6 +79,8 @@ private static readonly Action<ILogger, string, Exception> _DockerRegistryCreden
private static readonly Action<ILogger, string, Exception> _DockerRegistryCredentialFound
= LoggerMessage.Define<string>(LogLevel.Information, default, "Docker registry credential {DockerRegistry} found");

#pragma warning restore InconsistentNaming, SA1309

public static void IgnorePatternAdded(this ILogger logger, Regex ignorePattern)
{
_IgnorePatternAdded(logger, ignorePattern, null);
Expand Down