From cb2cd44aea79be9bcf27e064906747dd1036d921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Wed, 29 May 2024 09:58:22 +0200 Subject: [PATCH 1/2] Do not force LogLevel.Debug for DEBUG builds Never override an explicit `--log-level` option, even in DEBUG builds but default to the `Debug` log level for DEBUG builds and keep the `Warning` default for RELEASE builds. --- src/kiota/Handlers/BaseKiotaCommandHandler.cs | 3 --- src/kiota/KiotaHost.cs | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/kiota/Handlers/BaseKiotaCommandHandler.cs b/src/kiota/Handlers/BaseKiotaCommandHandler.cs index f1f2ce5fb7..5cf3f62755 100644 --- a/src/kiota/Handlers/BaseKiotaCommandHandler.cs +++ b/src/kiota/Handlers/BaseKiotaCommandHandler.cs @@ -136,9 +136,6 @@ protected async Task CheckForNewVersionAsync(ILogger logger, CancellationToken c protected (ILoggerFactory, ILogger) GetLoggerAndFactory(InvocationContext context, string logFileRootPath = "") { LogLevel logLevel = context.ParseResult.GetValueForOption(LogLevelOption); -#if DEBUG - logLevel = logLevel > LogLevel.Debug ? LogLevel.Debug : logLevel; -#endif var loggerFactory = LoggerFactory.Create(builder => { var logFileAbsoluteRootPath = GetAbsolutePath(logFileRootPath); diff --git a/src/kiota/KiotaHost.cs b/src/kiota/KiotaHost.cs index 955d22e4a4..4aca8504b6 100644 --- a/src/kiota/KiotaHost.cs +++ b/src/kiota/KiotaHost.cs @@ -541,7 +541,12 @@ internal static (Option>, Option>) GetIncludeAndExclud } internal static Option GetLogLevelOption() { - var logLevelOption = new Option("--log-level", () => LogLevel.Warning, "The log level to use when logging messages to the main output."); +#if DEBUG + static LogLevel DefaultLogLevel() => LogLevel.Debug; +#else + static LogLevel DefaultLogLevel() => LogLevel.Warning; +#endif + var logLevelOption = new Option("--log-level", DefaultLogLevel, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("--ll"); AddEnumValidator(logLevelOption, "log level"); return logLevelOption; From d2681e3eebb226d90d1b1f0b02f874aa2075ac3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Wed, 29 May 2024 15:35:52 +0200 Subject: [PATCH 2/2] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0985b86ce3..8a91a69048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added uri-form encoded serialization for PHP. [#2074](https://github.com/microsoft/kiota/issues/2074) - Added information message with base URL in the CLI experience. [#4635](https://github.com/microsoft/kiota/issues/4635) - Added optional parameter --disable-ssl-validation for generate, show, and download commands. [#4176](https://github.com/microsoft/kiota/issues/4176) +- For *Debug* builds of kiota, the `--log-level` / `--ll` option is now observed if specified explicitly on the command line. It still defaults to `Debug` for *Debug* builds and `Warning` for *Release* builds. [#4739](https://github.com/microsoft/kiota/pull/4739) ### Changed