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

linting fixes #5898

Merged
merged 1 commit into from
Dec 12, 2024
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
2 changes: 1 addition & 1 deletion src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private async Task CleanOutputDirectoryAsync(CancellationToken cancellationToken
Directory.Delete(subDir, true);
await workspaceManagementService.BackupStateAsync(config.OutputPath, cancellationToken).ConfigureAwait(false);
foreach (var subFile in Directory.EnumerateFiles(config.OutputPath)
.Where(x => !x.EndsWith(FileLogLogger.LogFileName, StringComparison.OrdinalIgnoreCase)))
.Where(static x => !x.EndsWith(FileLogLogger.LogFileName, StringComparison.OrdinalIgnoreCase)))
File.Delete(subFile);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/Kiota.Builder/Logging/FileLogLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
}
}

public class FileLogLogger<T> : FileLogLogger, ILogger<T>
public class FileLogLogger<T>(string logFileDirectoryAbsolutePath, LogLevel logLevel) : FileLogLogger(logFileDirectoryAbsolutePath, logLevel, typeof(T).FullName ?? string.Empty), ILogger<T>
{
public FileLogLogger(string logFileDirectoryAbsolutePath, LogLevel logLevel) : base(logFileDirectoryAbsolutePath, logLevel, typeof(T).FullName ?? string.Empty)
{
}
}
13 changes: 4 additions & 9 deletions src/Kiota.Builder/Logging/FileLogLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@

namespace Kiota.Builder.Logging;

public sealed class FileLogLoggerProvider : ILoggerProvider
public sealed class FileLogLoggerProvider(string logFileDirectoryAbsolutePath, LogLevel logLevel) : ILoggerProvider
{
private readonly LogLevel _logLevel;
private readonly string _logFileDirectoryAbsolutePath;
public FileLogLoggerProvider(string logFileDirectoryAbsolutePath, LogLevel logLevel)
{
_logLevel = logLevel;
_logFileDirectoryAbsolutePath = logFileDirectoryAbsolutePath;
}
private readonly List<FileLogLogger> _loggers = new();
private readonly LogLevel _logLevel = logLevel;
private readonly string _logFileDirectoryAbsolutePath = logFileDirectoryAbsolutePath;
private readonly List<FileLogLogger> _loggers = [];
public ILogger CreateLogger(string categoryName)
{
var instance = new FileLogLogger(_logFileDirectoryAbsolutePath, _logLevel, categoryName);
Expand Down
2 changes: 1 addition & 1 deletion src/kiota/Handlers/BaseKiotaCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected async Task CheckForNewVersionAsync(ILogger logger, CancellationToken c
DisplayWarning(result);
}
public abstract Task<int> InvokeAsync(InvocationContext context);
private readonly List<IDisposable> disposables = new();
private readonly List<IDisposable> disposables = [];
protected (ILoggerFactory, ILogger<T>) GetLoggerAndFactory<T>(InvocationContext context, string logFileRootPath = "")
{
LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption);
Expand Down
Loading