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 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;