Skip to content

Commit 8c91074

Browse files
committed
Add warning logging for requirement checks with warnings
Introduce LogCheckWarning helper to log warning messages when checks cannot be automatically verified. Update ExecuteCheckWithLoggingAsync to use this method for results marked as warnings, ensuring clearer logging for checks that pass with warnings. Minor formatting improvements included.
1 parent 678cfce commit 8c91074

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/Microsoft.Agents.A365.DevTools.Cli/Services/Requirements/RequirementCheck.cs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ protected virtual void LogCheckSuccess(ILogger logger, string? details = null)
4343
}
4444
}
4545

46+
/// <summary>
47+
/// Helper method to log check warning
48+
/// </summary>
49+
protected virtual void LogCheckWarning(ILogger logger, string? details = null)
50+
{
51+
logger.LogWarning("[WARNING] {Name}: Cannot automatically verify", Name);
52+
if (!string.IsNullOrWhiteSpace(details))
53+
{
54+
logger.LogWarning(" Details: {Details}", details);
55+
}
56+
}
57+
4658
/// <summary>
4759
/// Helper method to log check failure
4860
/// </summary>
@@ -57,35 +69,42 @@ protected virtual void LogCheckFailure(ILogger logger, string errorMessage, stri
5769
/// Helper method to execute the check with consistent logging
5870
/// </summary>
5971
protected async Task<RequirementCheckResult> ExecuteCheckWithLoggingAsync(
60-
Agent365Config config,
61-
ILogger logger,
72+
Agent365Config config,
73+
ILogger logger,
6274
Func<Agent365Config, ILogger, CancellationToken, Task<RequirementCheckResult>> checkImplementation,
6375
CancellationToken cancellationToken = default)
6476
{
6577
LogCheckStart(logger);
66-
78+
6779
try
6880
{
6981
var result = await checkImplementation(config, logger, cancellationToken);
70-
82+
7183
if (result.Passed)
7284
{
73-
LogCheckSuccess(logger, result.Details);
85+
if (result.IsWarning)
86+
{
87+
LogCheckWarning(logger, result.Details);
88+
}
89+
else
90+
{
91+
LogCheckSuccess(logger, result.Details);
92+
}
7493
}
7594
else
7695
{
7796
LogCheckFailure(logger, result.ErrorMessage ?? "Check failed", result.ResolutionGuidance ?? "No guidance available");
7897
}
79-
98+
8099
return result;
81100
}
82101
catch (Exception ex)
83102
{
84103
var errorMessage = $"Exception during check: {ex.Message}";
85104
var resolutionGuidance = "Please check the logs for more details and ensure all prerequisites are met";
86-
105+
87106
LogCheckFailure(logger, errorMessage, resolutionGuidance);
88-
107+
89108
return RequirementCheckResult.Failure(errorMessage, resolutionGuidance, ex.ToString());
90109
}
91110
}

0 commit comments

Comments
 (0)