Skip to content

Commit

Permalink
Merge pull request #4739 from 0xced/DefaultLogLevel
Browse files Browse the repository at this point in the history
Do not force LogLevel.Debug for DEBUG builds
  • Loading branch information
andrueastman authored May 30, 2024
2 parents 14c6820 + d2681e3 commit 942d5b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions src/kiota/Handlers/BaseKiotaCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ protected async Task CheckForNewVersionAsync(ILogger logger, CancellationToken c
protected (ILoggerFactory, ILogger<T>) GetLoggerAndFactory<T>(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);
Expand Down
7 changes: 6 additions & 1 deletion src/kiota/KiotaHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,12 @@ internal static (Option<List<string>>, Option<List<string>>) GetIncludeAndExclud
}
internal static Option<LogLevel> GetLogLevelOption()
{
var logLevelOption = new Option<LogLevel>("--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<LogLevel>("--log-level", DefaultLogLevel, "The log level to use when logging messages to the main output.");
logLevelOption.AddAlias("--ll");
AddEnumValidator(logLevelOption, "log level");
return logLevelOption;
Expand Down

0 comments on commit 942d5b9

Please sign in to comment.