Skip to content

[Bug]: dab validate outputs too much #3266

@JerryNixon

Description

@JerryNixon

What?

Dab validate should only show problems: Warnings or Errors. Also, incorrect output string.

  • Never show information except in the preamble and "Config is valid" at the end.
  • Do not print enum.ToString(), instead use standard output strings.

Apologies to @RubenCerna2079 who tried to explain this to me earlier.

Standarize Log Level output strings

DAB

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel) || logLevel < _minimumLogLevel)
{
return;
}
ConsoleColor originalForeGroundColor = Console.ForegroundColor;
ConsoleColor originalBackGroundColor = Console.BackgroundColor;
Console.ForegroundColor = _logLevelToForeGroundConsoleColorMap[logLevel];
Console.BackgroundColor = _logLevelToBackGroundConsoleColorMap[logLevel];
Console.Write($"{logLevel}:");
Console.ForegroundColor = originalForeGroundColor;
Console.BackgroundColor = originalBackGroundColor;
Console.WriteLine($" {formatter(state, exception)}");
}

ASPNETCORE
https://github.com/dotnet/aspnetcore/blob/f8410f812a2a76401468a78a4f776586c3af498c/src/Components/WebAssembly/WebAssembly/src/Services/WebAssemblyConsoleLogger.cs#L138-L158

Actual output

C:\Temp\dab-todo-test>dab validate
Information: Microsoft.DataApiBuilder 2.0.0
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Information: Environment variable DAB_ENVIRONMENT is Development
Information: Validating config file: dab-config.json
Information: The config satisfies the schema requirements.
Information: Validating entity relationships.
Information: [Todo] REST path: /api//Todo
Information: [MarkTodoComplete] REST path: /api//MarkTodoComplete
Information: Config is valid.

Desired output

valid

C:\Temp\dab-todo-test>dab validate
info: Microsoft.DataApiBuilder 2.0.0
info: Validating config file: dab-config.json
info: Config is invalid.

invalid

C:\Temp\dab-todo-test>dab validate
info: Microsoft.DataApiBuilder 2.0.0
info: Validating config file: dab-config.json
fail: {whatever is found wrong message here}
info: Config is valid.
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions