Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
824c4d3
structured logger formatter prototype
maryamariyan Apr 15, 2020
833b53d
add ref to Linq + add public apis
maryamariyan Apr 15, 2020
1f02cdc
New APIs for Structured Log Formatting
maryamariyan May 12, 2020
8ecb51e
Apply review feedback
maryamariyan May 14, 2020
ed1f429
nit cleanup
maryamariyan May 14, 2020
4516d5a
- messages can color vars in messages (Compact)
maryamariyan May 15, 2020
ae2e2fa
TODO
maryamariyan May 15, 2020
b89910d
Rename to XConsoleLog...
maryamariyan May 15, 2020
ecf8bdd
FormatterNames const not instance properties
maryamariyan May 15, 2020
fc946f0
add AddCompact and other helpers
maryamariyan May 15, 2020
8ebc659
Rename AddCompactFormatter for short?
maryamariyan May 15, 2020
5141aba
Revert "Rename AddCompactFormatter for short?"
maryamariyan May 21, 2020
6d04fb4
Add back deprecated APIs
maryamariyan May 21, 2020
b9a004e
exception messaging in compact remains single line
maryamariyan May 21, 2020
44906fb
cleanup
maryamariyan May 26, 2020
bdb4244
rename default to colored
maryamariyan May 26, 2020
d2e187a
deprecate ConsoleLoggerFormat
maryamariyan May 26, 2020
bc056e2
minor rename
maryamariyan May 26, 2020
6ffc7e7
Rename back to default formatter
maryamariyan May 27, 2020
58d3e88
triple slash comments on new helpers
maryamariyan May 28, 2020
f514a8c
slight impl fixup
maryamariyan May 28, 2020
c4bc2ef
ConsoleLoggerProvider: keep ctor not deprecate
maryamariyan May 28, 2020
0b41bed
Added triple slash comments
maryamariyan May 28, 2020
fa81978
corner cases
maryamariyan May 29, 2020
22d2eff
version 3 log formatter
maryamariyan Jun 11, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ public static partial class ConsoleLoggerExtensions
{
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsole(this Microsoft.Extensions.Logging.ILoggingBuilder builder) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsole(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action<Microsoft.Extensions.Logging.Console.ConsoleLoggerOptions> configure) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsole(this Microsoft.Extensions.Logging.ILoggingBuilder builder, string formatterName) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsoleLogFormatter<TFormatter, TOptions>(this Microsoft.Extensions.Logging.ILoggingBuilder builder) where TFormatter : class, Microsoft.Extensions.Logging.Console.IConsoleLogFormatter where TOptions : class, Microsoft.Extensions.Logging.Console.IConsoleLogFormatterOptions { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddConsoleLogFormatter<TFormatter, TOptions>(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action<TOptions> configure) where TFormatter : class, Microsoft.Extensions.Logging.Console.IConsoleLogFormatter where TOptions : class, Microsoft.Extensions.Logging.Console.IConsoleLogFormatterOptions { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddDefaultConsoleLogFormatter(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action<Microsoft.Extensions.Logging.Console.DefaultConsoleLogFormatterOptions> configure) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddJsonConsoleLogFormatter(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action<Microsoft.Extensions.Logging.Console.JsonConsoleLogFormatterOptions> configure) { throw null; }
public static Microsoft.Extensions.Logging.ILoggingBuilder AddSystemdConsoleLogFormatter(this Microsoft.Extensions.Logging.ILoggingBuilder builder, System.Action<Microsoft.Extensions.Logging.Console.SystemdConsoleLogFormatterOptions> configure) { throw null; }
}
}
namespace Microsoft.Extensions.Logging.Console
{
public static partial class ConsoleLogFormatterNames
{
public const string Default = "default";
public const string Json = "json";
public const string Systemd = "systemd";
}
[System.ObsoleteAttribute("ConsoleLoggerFormat has been deprecated.", false)]
public enum ConsoleLoggerFormat
{
Default = 0,
Expand All @@ -23,19 +36,75 @@ public enum ConsoleLoggerFormat
public partial class ConsoleLoggerOptions
{
public ConsoleLoggerOptions() { }
[System.ObsoleteAttribute("ConsoleLoggerOptions.DisableColors has been deprecated. Please use ColoredConsoleLogFormatterOptions.DisableColors instead.", false)]
public bool DisableColors { get { throw null; } set { } }
[System.ObsoleteAttribute("ConsoleLoggerOptions.Format has been deprecated. Please use ConsoleLoggerOptions.FormatterName instead.", false)]
public Microsoft.Extensions.Logging.Console.ConsoleLoggerFormat Format { get { throw null; } set { } }
public string FormatterName { get { throw null; } set { } }
[System.ObsoleteAttribute("ConsoleLoggerOptions.IncludeScopes has been deprecated..", false)]
public bool IncludeScopes { get { throw null; } set { } }
[System.ObsoleteAttribute("ConsoleLoggerOptions.LogToStandardErrorThreshold has been deprecated..", false)]
public Microsoft.Extensions.Logging.LogLevel LogToStandardErrorThreshold { get { throw null; } set { } }
[System.ObsoleteAttribute("ConsoleLoggerOptions.TimestampFormat has been deprecated..", false)]
public string TimestampFormat { get { throw null; } set { } }
[System.ObsoleteAttribute("ConsoleLoggerOptions.UseUtcTimestamp has been deprecated..", false)]
public bool UseUtcTimestamp { get { throw null; } set { } }
}
[Microsoft.Extensions.Logging.ProviderAliasAttribute("Console")]
public partial class ConsoleLoggerProvider : Microsoft.Extensions.Logging.ILoggerProvider, Microsoft.Extensions.Logging.ISupportExternalScope, System.IDisposable
{
public ConsoleLoggerProvider(Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.Extensions.Logging.Console.ConsoleLoggerOptions> options) { }
public ConsoleLoggerProvider(Microsoft.Extensions.Options.IOptionsMonitor<Microsoft.Extensions.Logging.Console.ConsoleLoggerOptions> options, System.Collections.Generic.IEnumerable<Microsoft.Extensions.Logging.Console.IConsoleLogFormatter> formatters) { }
public Microsoft.Extensions.Logging.ILogger CreateLogger(string name) { throw null; }
public void Dispose() { }
public void SetScopeProvider(Microsoft.Extensions.Logging.IExternalScopeProvider scopeProvider) { }
}
public partial class DefaultConsoleLogFormatterOptions : Microsoft.Extensions.Logging.Console.IConsoleLogFormatterOptions
{
public DefaultConsoleLogFormatterOptions() { }
public bool DisableColors { get { throw null; } set { } }
public bool IncludeScopes { get { throw null; } set { } }
public Microsoft.Extensions.Logging.LogLevel LogToStandardErrorThreshold { get { throw null; } set { } }
public bool MultiLine { get { throw null; } set { } }
public string TimestampFormat { get { throw null; } set { } }
public bool UseUtcTimestamp { get { throw null; } set { } }
}
public partial interface IConsoleLogFormatter
{
string Name { get; }
void Format<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, string logName, Microsoft.Extensions.Logging.EventId eventId, TState state, System.Exception exception, System.Func<TState, System.Exception, string> formatter, Microsoft.Extensions.Logging.IExternalScopeProvider scopeProvider, Microsoft.Extensions.Logging.Console.IConsoleMessageBuilder consoleMessageBuilder);
}
public partial interface IConsoleLogFormatterOptions
{
bool IncludeScopes { get; set; }
Microsoft.Extensions.Logging.LogLevel LogToStandardErrorThreshold { get; set; }
string TimestampFormat { get; set; }
bool UseUtcTimestamp { get; set; }
}
public partial interface IConsoleMessageBuilder
{
bool LogAsError { get; set; }
Microsoft.Extensions.Logging.Console.IConsoleMessageBuilder Append(string message);
Microsoft.Extensions.Logging.Console.IConsoleMessageBuilder Build();
void Clear();
Microsoft.Extensions.Logging.Console.IConsoleMessageBuilder ResetColor();
Microsoft.Extensions.Logging.Console.IConsoleMessageBuilder SetColor(System.ConsoleColor? background, System.ConsoleColor? foreground);
}
public partial class JsonConsoleLogFormatterOptions : Microsoft.Extensions.Logging.Console.IConsoleLogFormatterOptions
{
public JsonConsoleLogFormatterOptions() { }
public bool IncludeScopes { get { throw null; } set { } }
public System.Text.Json.JsonWriterOptions JsonWriterOptions { get { throw null; } set { } }
public Microsoft.Extensions.Logging.LogLevel LogToStandardErrorThreshold { get { throw null; } set { } }
public string TimestampFormat { get { throw null; } set { } }
public bool UseUtcTimestamp { get { throw null; } set { } }
}
public partial class SystemdConsoleLogFormatterOptions : Microsoft.Extensions.Logging.Console.IConsoleLogFormatterOptions
{
public SystemdConsoleLogFormatterOptions() { }
public bool IncludeScopes { get { throw null; } set { } }
public Microsoft.Extensions.Logging.LogLevel LogToStandardErrorThreshold { get { throw null; } set { } }
public string TimestampFormat { get { throw null; } set { } }
public bool UseUtcTimestamp { get { throw null; } set { } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<ItemGroup>
<Compile Include="Microsoft.Extensions.Logging.Console.cs" />
<ProjectReference Include="..\..\System.Text.Json\ref\System.Text.Json.csproj" />
<ProjectReference Include="..\..\Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj" />
<ProjectReference Include="..\..\Microsoft.Extensions.Logging\ref\Microsoft.Extensions.Logging.csproj" />
<ProjectReference Include="..\..\Microsoft.Extensions.Options\ref\Microsoft.Extensions.Options.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace Microsoft.Extensions.Logging.Console
/// </summary>
internal class AnsiLogConsole : IConsole
{
private const string DefaultForegroundColor = "\x1B[39m\x1B[22m";
private const string DefaultBackgroundColor = "\x1B[49m";

private readonly StringBuilder _outputBuilder;
private readonly IAnsiSystemConsole _systemConsole;

Expand Down Expand Up @@ -94,7 +97,7 @@ private static string GetForegroundColorEscapeCode(ConsoleColor color)
case ConsoleColor.White:
return "\x1B[1m\x1B[37m";
default:
return "\x1B[39m\x1B[22m"; // default foreground color
return DefaultForegroundColor; // default foreground color
}
}

Expand All @@ -119,7 +122,7 @@ private static string GetBackgroundColorEscapeCode(ConsoleColor color)
case ConsoleColor.White:
return "\x1B[47m";
default:
return "\x1B[49m"; // Use default background color
return DefaultBackgroundColor; // Use default background color
}
}
}
Expand Down
Loading