Skip to content

Commit 0e0e6e1

Browse files
Centralize logging env vars in ConfigurationConstants
Move all logging-related environment variable constants to a new ConfigurationConstants class for better maintainability. Update all usages in builder and ensemble classes to reference the centralized constants. Ensure builder methods are chainable and update builder state as expected. Add copyright and license header to the new file. sign off by: nagavo Signed-off-by: Santhosh Reddy Vootukuri (SUNNY) <nagavo@microsoft.com>
1 parent f834466 commit 0e0e6e1

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// Copyright The Microcks Authors.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License")
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
//
17+
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Text;
22+
using System.Threading.Tasks;
23+
24+
namespace Microcks.Testcontainers.Helpers
25+
{
26+
public class ConfigurationConstants
27+
{
28+
/// <summary>
29+
/// Environment variable name used to configure Microcks logging level for the Microcks package.
30+
/// </summary>
31+
public const string MicrocksLoggingLevelEnvVar = "LOGGING_LEVEL_IO_GITHUB_MICROCKS";
32+
33+
/// <summary>
34+
/// Environment variable value for enabling DEBUG logging.
35+
/// </summary>
36+
public const string DebugLogLevel = "DEBUG";
37+
38+
/// <summary>
39+
/// Environment variable name used by Quarkus to configure console log level.
40+
/// </summary>
41+
public const string QuarkusConsoleLogLevelEnvVar = "QUARKUS_LOG_CONSOLE_LEVEL";
42+
43+
/// <summary>
44+
/// Environment variable name used by Quarkus to configure the Microcks category log level.
45+
/// </summary>
46+
public const string QuarkusMicrocksCategoryLogLevelEnvVar = "QUARKUS_LOG_CATEGORY__IO_GITHUB_MICROCKS__LEVEL";
47+
}
48+
}

src/Microcks.Testcontainers/MicrocksAsyncMinionBuilder.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
using DotNet.Testcontainers.Networks;
2020
using Microcks.Testcontainers.Connection;
21+
using Microcks.Testcontainers.Helpers;
2122

2223
namespace Microcks.Testcontainers;
2324

@@ -134,20 +135,6 @@ public MicrocksAsyncMinionBuilder WithAmqpConnection(GenericConnection amqpConne
134135
return Merge(DockerResourceConfiguration, new MicrocksAsyncMinionConfiguration(new ContainerConfiguration(environments: environments)));
135136
}
136137

137-
/// <summary>
138-
/// Environment variable name used by Quarkus to configure console log level.
139-
/// </summary>
140-
public const string QuarkusConsoleLogLevelEnvVar = "QUARKUS_LOG_CONSOLE_LEVEL";
141-
142-
/// <summary>
143-
/// Environment variable name used by Quarkus to configure the Microcks category log level.
144-
/// </summary>
145-
public const string QuarkusMicrocksCategoryLogLevelEnvVar = "QUARKUS_LOG_CATEGORY__IO_GITHUB_MICROCKS__LEVEL";
146-
147-
/// <summary>
148-
/// Environment variable value for enabling DEBUG logging.
149-
/// </summary>
150-
public const string DebugLogLevel = "DEBUG";
151138

152139
/// <summary>
153140
/// Enables DEBUG log level for Microcks async minion components inside the container.
@@ -159,7 +146,7 @@ public MicrocksAsyncMinionBuilder WithAmqpConnection(GenericConnection amqpConne
159146
public MicrocksAsyncMinionBuilder WithDebugLogLevel()
160147
{
161148
return this
162-
.WithEnvironment(QuarkusConsoleLogLevelEnvVar, DebugLogLevel)
163-
.WithEnvironment(QuarkusMicrocksCategoryLogLevelEnvVar, DebugLogLevel);
149+
.WithEnvironment(ConfigurationConstants.QuarkusConsoleLogLevelEnvVar, ConfigurationConstants.DebugLogLevel)
150+
.WithEnvironment(ConfigurationConstants.QuarkusMicrocksCategoryLogLevelEnvVar, ConfigurationConstants.DebugLogLevel);
164151
}
165152
}

src/Microcks.Testcontainers/MicrocksBuilder.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ public sealed class MicrocksBuilder : ContainerBuilder<MicrocksBuilder, Microcks
3838
/// </summary>
3939
public const ushort MicrocksGrpcPort = 9090;
4040

41-
/// <summary>
42-
/// Environment variable name used to configure Microcks logging level for the Microcks package.
43-
/// </summary>
44-
public const string MicrocksLoggingLevelEnvVar = "LOGGING_LEVEL_IO_GITHUB_MICROCKS";
45-
46-
/// <summary>
47-
/// Environment variable value for enabling DEBUG logging.
48-
/// </summary>
49-
public const string DebugLogLevel = "DEBUG";
50-
5141
private List<string> _snapshots;
5242

5343
private List<string> _mainArtifacts;
@@ -284,6 +274,6 @@ public MicrocksBuilder WithSecrets(params Model.Secret[] secrets)
284274
/// </summary>
285275
public MicrocksBuilder WithDebugLogLevel()
286276
{
287-
return this.WithEnvironment(MicrocksLoggingLevelEnvVar, DebugLogLevel);
277+
return this.WithEnvironment(ConfigurationConstants.MicrocksLoggingLevelEnvVar, ConfigurationConstants.DebugLogLevel);
288278
}
289279
}

src/Microcks.Testcontainers/MicrocksContainerEnsemble.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Microcks.Testcontainers;
2929
/// </summary>
3030
public class MicrocksContainerEnsemble : IAsyncDisposable, IArtifactAndSnapshotManager<MicrocksContainerEnsemble>
3131
{
32-
private readonly MicrocksBuilder _microcksBuilder;
32+
private MicrocksBuilder _microcksBuilder;
3333

3434
private ContainerBuilder _postmanBuilder;
3535
private MicrocksAsyncMinionBuilder _asyncMinionBuilder;
@@ -190,7 +190,7 @@ public MicrocksContainerEnsemble WithAsyncFeature()
190190

191191
if (this._debugLogLevelEnabled)
192192
{
193-
this._asyncMinionBuilder.WithDebugLogLevel();
193+
this._asyncMinionBuilder = this._asyncMinionBuilder.WithDebugLogLevel();
194194
}
195195

196196
return this;
@@ -238,10 +238,10 @@ public MicrocksContainerEnsemble WithAmqpConnection(GenericConnection amqpConnec
238238
public MicrocksContainerEnsemble WithDebugLogLevel()
239239
{
240240
this._debugLogLevelEnabled = true;
241-
this._microcksBuilder.WithDebugLogLevel();
241+
this._microcksBuilder = this._microcksBuilder.WithDebugLogLevel();
242242

243243
// If async feature has already been enabled, apply immediately.
244-
this._asyncMinionBuilder?.WithDebugLogLevel();
244+
this._asyncMinionBuilder = this._asyncMinionBuilder?.WithDebugLogLevel();
245245

246246
return this;
247247
}

0 commit comments

Comments
 (0)