Skip to content

Commit e5aac51

Browse files
committed
Ensure file is scoped to path and log both
1 parent 6ec11b6 commit e5aac51

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/tooling/docs-builder/Cli/InboundLinkCommands.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ namespace Documentation.Builder.Cli;
1818
internal sealed class InboundLinkCommands(ILoggerFactory logger, ICoreService githubActionsService)
1919
{
2020
private readonly LinkIndexLinkChecker _linkIndexLinkChecker = new(logger);
21+
private readonly ILogger<Program> _log = logger.CreateLogger<Program>();
2122

2223
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
2324
private void AssignOutputLogger()
2425
{
25-
var log = logger.CreateLogger<Program>();
26-
ConsoleApp.Log = msg => log.LogInformation(msg);
27-
ConsoleApp.LogError = msg => log.LogError(msg);
26+
ConsoleApp.Log = msg => _log.LogInformation(msg);
27+
ConsoleApp.LogError = msg => _log.LogError(msg);
2828
}
2929

3030
/// <summary> Validate all published cross_links in all published links.json files. </summary>
@@ -83,8 +83,11 @@ public async Task<int> ValidateLocalLinkReference(string? file = null, string? p
8383
var repository = GitCheckoutInformation.Create(root, new FileSystem(), logger.CreateLogger(nameof(GitCheckoutInformation))).RepositoryName
8484
?? throw new Exception("Unable to determine repository name");
8585

86+
var resolvedFile = Path.Combine(root.FullName, file);
87+
_log.LogInformation("Validating {File} in {Directory}", file, root.FullName);
88+
8689
await using var collector = new ConsoleDiagnosticsCollector(logger, githubActionsService).StartAsync(ctx);
87-
await _linkIndexLinkChecker.CheckWithLocalLinksJson(collector, repository, file, ctx);
90+
await _linkIndexLinkChecker.CheckWithLocalLinksJson(collector, repository, resolvedFile, ctx);
8891
await collector.StopAsync(ctx);
8992
return collector.Errors;
9093
}

0 commit comments

Comments
 (0)