Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ggobbe committed Dec 22, 2021
1 parent 4749eb0 commit b6a4ae6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following built-in themes are available:
* `AnsiConsoleTheme.Literate` - an ANSI 256-color version of the "literate" theme
* `AnsiConsoleTheme.Grayscale` - an ANSI 256-color version of the "grayscale" theme
* `AnsiConsoleTheme.Code` - an ANSI 256-color Visual Studio Code-inspired theme
* `AnsiConsoleTheme.Sixteen` - an ANSI 16-color version of the "literate" theme that works with light and dark backgrounds
* `AnsiConsoleTheme.Sixteen` - an ANSI 16-color theme that works well with both light and dark backgrounds

Adding a new theme is straightforward; examples can be found in the [`SystemConsoleThemes`](https://github.com/serilog/serilog-sinks-console/blob/dev/src/Serilog.Sinks.Console/Sinks/SystemConsole/Themes/SystemConsoleThemes.cs) and [`AnsiConsoleThemes`](https://github.com/serilog/serilog-sinks-console/blob/dev/src/Serilog.Sinks.Console/Sinks/SystemConsole/Themes/AnsiConsoleThemes.cs) classes.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@ namespace Serilog.Sinks.SystemConsole.Themes
{
static class AnsiConsoleThemes
{
const string Reset = "\x1b[0m";
const string Bold = "\x1b[1m";

const string Black = "\x1b[30m";
const string Red = "\x1b[31m";
const string Green = "\x1b[32m";
const string Yellow = "\x1b[33m";
const string Blue = "\x1b[34m";
const string Magenta = "\x1b[35m";
const string Cyan = "\x1b[36m";
const string White = "\x1b[37m";

const string BrightBlack = "\x1b[30;1m";
const string BrightRed = "\x1b[31;1m";
const string BrightGreen = "\x1b[32;1m";
const string BrightYellow = "\x1b[33;1m";
const string BrightBlue = "\x1b[34;1m";
const string BrightMagenta = "\x1b[35;1m";
const string BrightCyan = "\x1b[36;1m";
const string BrightWhite = "\x1b[37;1m";

public static AnsiConsoleTheme Literate { get; } = new AnsiConsoleTheme(
new Dictionary<ConsoleThemeStyle, string>
{
Expand Down Expand Up @@ -105,22 +84,22 @@ static class AnsiConsoleThemes
public static AnsiConsoleTheme Sixteen { get; } = new AnsiConsoleTheme(
new Dictionary<ConsoleThemeStyle, string>
{
[ConsoleThemeStyle.Text] = Reset,
[ConsoleThemeStyle.SecondaryText] = Reset,
[ConsoleThemeStyle.TertiaryText] = Reset,
[ConsoleThemeStyle.Invalid] = Yellow,
[ConsoleThemeStyle.Null] = Blue,
[ConsoleThemeStyle.Name] = Reset,
[ConsoleThemeStyle.String] = Cyan,
[ConsoleThemeStyle.Number] = Magenta,
[ConsoleThemeStyle.Boolean] = Blue,
[ConsoleThemeStyle.Scalar] = Green,
[ConsoleThemeStyle.LevelVerbose] = Reset,
[ConsoleThemeStyle.LevelDebug] = Bold,
[ConsoleThemeStyle.LevelInformation] = BrightCyan,
[ConsoleThemeStyle.LevelWarning] = BrightYellow,
[ConsoleThemeStyle.LevelError] = BrightRed,
[ConsoleThemeStyle.LevelFatal] = "\x1b[38;5;0015m\x1b[48;5;0196m",
[ConsoleThemeStyle.Text] = AnsiEscapeSequence.Unthemed,
[ConsoleThemeStyle.SecondaryText] = AnsiEscapeSequence.Unthemed,
[ConsoleThemeStyle.TertiaryText] = AnsiEscapeSequence.Unthemed,
[ConsoleThemeStyle.Invalid] = AnsiEscapeSequence.Yellow,
[ConsoleThemeStyle.Null] = AnsiEscapeSequence.Blue,
[ConsoleThemeStyle.Name] = AnsiEscapeSequence.Unthemed,
[ConsoleThemeStyle.String] = AnsiEscapeSequence.Cyan,
[ConsoleThemeStyle.Number] = AnsiEscapeSequence.Magenta,
[ConsoleThemeStyle.Boolean] = AnsiEscapeSequence.Blue,
[ConsoleThemeStyle.Scalar] = AnsiEscapeSequence.Green,
[ConsoleThemeStyle.LevelVerbose] = AnsiEscapeSequence.Unthemed,
[ConsoleThemeStyle.LevelDebug] = AnsiEscapeSequence.Bold,
[ConsoleThemeStyle.LevelInformation] = AnsiEscapeSequence.BrightCyan,
[ConsoleThemeStyle.LevelWarning] = AnsiEscapeSequence.BrightYellow,
[ConsoleThemeStyle.LevelError] = AnsiEscapeSequence.BrightRed,
[ConsoleThemeStyle.LevelFatal] = AnsiEscapeSequence.BrightRed,
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2017 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Serilog.Sinks.SystemConsole.Themes
{
static class AnsiEscapeSequence
{
public const string Unthemed = "";
public const string Reset = "\x1b[0m";
public const string Bold = "\x1b[1m";

public const string Black = "\x1b[30m";
public const string Red = "\x1b[31m";
public const string Green = "\x1b[32m";
public const string Yellow = "\x1b[33m";
public const string Blue = "\x1b[34m";
public const string Magenta = "\x1b[35m";
public const string Cyan = "\x1b[36m";
public const string White = "\x1b[37m";

public const string BrightBlack = "\x1b[30;1m";
public const string BrightRed = "\x1b[31;1m";
public const string BrightGreen = "\x1b[32;1m";
public const string BrightYellow = "\x1b[33;1m";
public const string BrightBlue = "\x1b[34;1m";
public const string BrightMagenta = "\x1b[35;1m";
public const string BrightCyan = "\x1b[36;1m";
public const string BrightWhite = "\x1b[37;1m";
}
}

0 comments on commit b6a4ae6

Please sign in to comment.