Skip to content

Commit 2188d03

Browse files
authored
Merge pull request #126 from Simnico99/ansi-colors
Added Ansi Sixteen (TemplateTheme Sixteen)
2 parents 555c284 + e0a8023 commit 2188d03

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/Serilog.Expressions/Templates/Themes/TemplateTheme.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public class TemplateTheme
3434
/// </summary>
3535
public static TemplateTheme Literate { get; } = TemplateThemes.Literate;
3636

37+
/// <summary>
38+
/// A theme in the style of the original <i>Serilog.Sinks.Literate</i> using only standard 16 terminal colors that will work on light backgrounds.
39+
/// </summary>
40+
public static TemplateTheme Sixteen { get; } = TemplateThemes.Sixteen;
41+
3742
internal static TemplateTheme None { get; } = new(new Dictionary<TemplateThemeStyle, string>());
3843

3944
readonly Dictionary<TemplateThemeStyle, Style> _styles;
@@ -71,4 +76,4 @@ internal Style GetStyle(TemplateThemeStyle templateThemeStyle)
7176
_styles.TryGetValue(templateThemeStyle, out var style);
7277
return style;
7378
}
74-
}
79+
}

src/Serilog.Expressions/Templates/Themes/TemplateThemes.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © Serilog Contributors
1+
// Copyright © Serilog Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -78,4 +78,25 @@ static class TemplateThemes
7878
[TemplateThemeStyle.LevelError] = "\x1b[38;5;0197m\x1b[48;5;0238m",
7979
[TemplateThemeStyle.LevelFatal] = "\x1b[38;5;0197m\x1b[48;5;0238m",
8080
});
81-
}
81+
82+
public static TemplateTheme Sixteen { get; } = new(
83+
new Dictionary<TemplateThemeStyle, string>
84+
{
85+
[TemplateThemeStyle.Text] = string.Empty,
86+
[TemplateThemeStyle.SecondaryText] = string.Empty,
87+
[TemplateThemeStyle.TertiaryText] = string.Empty,
88+
[TemplateThemeStyle.Invalid] = "\x1b[33m",
89+
[TemplateThemeStyle.Null] = "\x1b[34m",
90+
[TemplateThemeStyle.Name] = string.Empty,
91+
[TemplateThemeStyle.String] = "\x1b[36m",
92+
[TemplateThemeStyle.Number] = "\x1b[35m",
93+
[TemplateThemeStyle.Boolean] = "\x1b[34m",
94+
[TemplateThemeStyle.Scalar] = "\x1b[32m",
95+
[TemplateThemeStyle.LevelVerbose] = "\x1b[30;1m",
96+
[TemplateThemeStyle.LevelDebug] = "\x1b[1m",
97+
[TemplateThemeStyle.LevelInformation] = "\x1b[36;1m",
98+
[TemplateThemeStyle.LevelWarning] = "\x1b[33;1m",
99+
[TemplateThemeStyle.LevelError] = "\x1b[31;1m",
100+
[TemplateThemeStyle.LevelFatal] = "\x1b[31;1m",
101+
});
102+
}

0 commit comments

Comments
 (0)