Skip to content
Open
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 README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Spectre.Cli.Extensions.DependencyInjection
# Spectre.Console.Extensions.Logging

A highly opioninated logger implementation for [`Microsoft.Extensions.Logging`](https://www.nuget.org/packages/Microsoft.Extensions.Logging/) that uses [`Spectre.Console`](https://github.com/spectresystems/spectre.console) to write to the console.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.9" />
<PackageReference Include="Spectre.Console" Version="0.38.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Spectre.Console" Version="0.46.0" />
</ItemGroup>

</Project>
12 changes: 10 additions & 2 deletions src/Spectre.Console.Extensions.Logging/SpectreConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
var categoryStr = _config.IncludeEventId
? _name + $"[grey][[{eventId.Id}]][/]"
: _name;
_console.MarkupLine(prefix + categoryStr);
_console.MarkupLine(string.Empty.PadRight(6) + formatter(state, exception));

if (!_config.SingleLine)
{
_console.MarkupLine(prefix + categoryStr);
_console.MarkupLine(string.Empty.PadRight(6) + formatter(state, exception));
}
else
{
_console.MarkupLine(prefix + categoryStr + " " + formatter(state, exception));
}
}
}
private string GetLevelMarkup(LogLevel level) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class SpectreConsoleLoggerConfiguration
public AnsiConsoleSettings ConsoleSettings {get;set;} = null;
public bool IncludePrefix {get;set;} = true;
public bool IncludeEventId {get;set;} = false;
public bool SingleLine { get; set; } = false;
}
}