Skip to content

Commit 71d7cbe

Browse files
authored
Merge pull request #9 from nblumhardt/great-console-unification
Brought output template text color into line with previous literate theme
2 parents c961117 + 65b1557 commit 71d7cbe

File tree

6 files changed

+34
-33
lines changed

6 files changed

+34
-33
lines changed

src/Serilog.Sinks.Console/Sinks/SystemConsole/Formatting/ThemedDisplayValueFormatter.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ protected override int VisitSequenceValue(ThemedValueFormatterState state, Seque
4949

5050
var count = 0;
5151

52-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
52+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
5353
state.Output.Write('[');
5454

5555
var delim = "";
5656
for (var index = 0; index < sequence.Elements.Count; ++index)
5757
{
5858
if (delim.Length != 0)
59-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
59+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
6060
state.Output.Write(delim);
6161

6262
delim = ", ";
6363
Visit(state, sequence.Elements[index]);
6464
}
6565

66-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
66+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
6767
state.Output.Write(']');
6868

6969
return count;
@@ -81,14 +81,14 @@ protected override int VisitStructureValue(ThemedValueFormatterState state, Stru
8181
state.Output.Write(' ');
8282
}
8383

84-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
84+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
8585
state.Output.Write('{');
8686

8787
var delim = "";
8888
for (var index = 0; index < structure.Properties.Count; ++index)
8989
{
9090
if (delim.Length != 0)
91-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
91+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
9292
state.Output.Write(delim);
9393

9494
delim = ", ";
@@ -98,13 +98,13 @@ protected override int VisitStructureValue(ThemedValueFormatterState state, Stru
9898
using (ApplyStyle(state.Output, ConsoleThemeStyle.Name, ref count))
9999
state.Output.Write(property.Name);
100100

101-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
101+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
102102
state.Output.Write('=');
103103

104104
count += Visit(state.Nest(), property.Value);
105105
}
106106

107-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
107+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
108108
state.Output.Write('}');
109109

110110
return count;
@@ -114,31 +114,31 @@ protected override int VisitDictionaryValue(ThemedValueFormatterState state, Dic
114114
{
115115
var count = 0;
116116

117-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
117+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
118118
state.Output.Write('{');
119119

120120
var delim = "";
121121
foreach (var element in dictionary.Elements)
122122
{
123123
if (delim.Length != 0)
124-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
124+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
125125
state.Output.Write(delim);
126126

127127
delim = ", ";
128128

129-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
129+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
130130
state.Output.Write('[');
131131

132132
using (ApplyStyle(state.Output, ConsoleThemeStyle.String, ref count))
133133
count += Visit(state.Nest(), element.Key);
134134

135-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
135+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
136136
state.Output.Write("]=");
137137

138138
count += Visit(state.Nest(), element.Value);
139139
}
140140

141-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
141+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
142142
state.Output.Write('}');
143143

144144
return count;

src/Serilog.Sinks.Console/Sinks/SystemConsole/Formatting/ThemedJsonValueFormatter.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,21 @@ protected override int VisitSequenceValue(ThemedValueFormatterState state, Seque
5252

5353
var count = 0;
5454

55-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
55+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
5656
state.Output.Write('[');
5757

5858
var delim = "";
5959
for (var index = 0; index < sequence.Elements.Count; ++index)
6060
{
6161
if (delim.Length != 0)
62-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
62+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
6363
state.Output.Write(delim);
6464

6565
delim = ", ";
6666
Visit(state, sequence.Elements[index]);
6767
}
6868

69-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
69+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
7070
state.Output.Write(']');
7171

7272
return count;
@@ -76,14 +76,14 @@ protected override int VisitStructureValue(ThemedValueFormatterState state, Stru
7676
{
7777
var count = 0;
7878

79-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
79+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
8080
state.Output.Write('{');
8181

8282
var delim = "";
8383
for (var index = 0; index < structure.Properties.Count; ++index)
8484
{
8585
if (delim.Length != 0)
86-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
86+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
8787
state.Output.Write(delim);
8888

8989
delim = ", ";
@@ -93,27 +93,27 @@ protected override int VisitStructureValue(ThemedValueFormatterState state, Stru
9393
using (ApplyStyle(state.Output, ConsoleThemeStyle.Name, ref count))
9494
JsonValueFormatter.WriteQuotedJsonString(property.Name, state.Output);
9595

96-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
96+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
9797
state.Output.Write(": ");
9898

9999
count += Visit(state, property.Value);
100100
}
101101
if (structure.TypeTag != null)
102102
{
103-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
103+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
104104
state.Output.Write(delim);
105105

106106
using (ApplyStyle(state.Output, ConsoleThemeStyle.Name, ref count))
107107
JsonValueFormatter.WriteQuotedJsonString("$type", state.Output);
108108

109-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
109+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
110110
state.Output.Write(": ");
111111

112112
using (ApplyStyle(state.Output, ConsoleThemeStyle.String, ref count))
113113
JsonValueFormatter.WriteQuotedJsonString(structure.TypeTag, state.Output);
114114
}
115115

116-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
116+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
117117
state.Output.Write('}');
118118

119119
return count;
@@ -123,28 +123,28 @@ protected override int VisitDictionaryValue(ThemedValueFormatterState state, Dic
123123
{
124124
int count = 0;
125125

126-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
126+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
127127
state.Output.Write('{');
128128

129129
var delim = "";
130130
foreach (var element in dictionary.Elements)
131131
{
132132
if (delim.Length != 0)
133-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
133+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
134134
state.Output.Write(delim);
135135

136136
delim = ", ";
137137

138138
using (ApplyStyle(state.Output, ConsoleThemeStyle.String, ref count))
139139
JsonValueFormatter.WriteQuotedJsonString((element.Key.Value ?? "null").ToString(), state.Output);
140140

141-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
141+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
142142
state.Output.Write(": ");
143143

144144
count += Visit(state, element.Value);
145145
}
146146

147-
using (ApplyStyle(state.Output, ConsoleThemeStyle.Punctuation, ref count))
147+
using (ApplyStyle(state.Output, ConsoleThemeStyle.TertiaryText, ref count))
148148
state.Output.Write('}');
149149

150150
return count;

src/Serilog.Sinks.Console/Sinks/SystemConsole/Output/TextTokenRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public TextTokenRenderer(ConsoleTheme theme, string text)
3232
public override void Render(LogEvent logEvent, TextWriter output)
3333
{
3434
var _ = 0;
35-
using (_theme.Apply(output, ConsoleThemeStyle.SecondaryText, ref _))
35+
using (_theme.Apply(output, ConsoleThemeStyle.TertiaryText, ref _))
3636
output.Write(_text);
3737
}
3838
}

src/Serilog.Sinks.Console/Sinks/SystemConsole/Themes/AnsiConsoleThemes.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static class AnsiConsoleThemes
2323
{
2424
[ConsoleThemeStyle.Text] = "\x1b[37;1m",
2525
[ConsoleThemeStyle.SecondaryText] = "\x1b[37m",
26-
[ConsoleThemeStyle.Punctuation] = "\x1b[30;1m",
26+
[ConsoleThemeStyle.TertiaryText] = "\x1b[30;1m",
2727
[ConsoleThemeStyle.Invalid] = "\x1b[33;1m",
2828
[ConsoleThemeStyle.Null] = "\x1b[34;1m",
2929
[ConsoleThemeStyle.Name] = "\x1b[37m",
@@ -44,7 +44,7 @@ static class AnsiConsoleThemes
4444
{
4545
[ConsoleThemeStyle.Text] = "\x1b[37;1m",
4646
[ConsoleThemeStyle.SecondaryText] = "\x1b[37m",
47-
[ConsoleThemeStyle.Punctuation] = "\x1b[30;1m",
47+
[ConsoleThemeStyle.TertiaryText] = "\x1b[30;1m",
4848
[ConsoleThemeStyle.Invalid] = "\x1b[37;1m\x1b[47m",
4949
[ConsoleThemeStyle.Null] = "\x1b[1m\x1b[37;1m",
5050
[ConsoleThemeStyle.Name] = "\x1b[37m",
@@ -65,7 +65,7 @@ static class AnsiConsoleThemes
6565
{
6666
[ConsoleThemeStyle.Text] = "\x1b[38;5;0253m",
6767
[ConsoleThemeStyle.SecondaryText] = "\x1b[38;5;0246m",
68-
[ConsoleThemeStyle.Punctuation] = "\x1b[38;5;0253m",
68+
[ConsoleThemeStyle.TertiaryText] = "\x1b[38;5;0253m",
6969
[ConsoleThemeStyle.Invalid] = "\x1b[33;1m",
7070
[ConsoleThemeStyle.Null] = "\x1b[38;5;0038m",
7171
[ConsoleThemeStyle.Name] = "\x1b[38;5;0081m",

src/Serilog.Sinks.Console/Sinks/SystemConsole/Themes/ConsoleThemeStyle.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ public enum ConsoleThemeStyle
3030
SecondaryText,
3131

3232
/// <summary>
33-
/// Punctuation used when writing structured data.
33+
/// De-emphasized text, for example literal text in output templates and
34+
/// punctuation used when writing structured data.
3435
/// </summary>
35-
Punctuation,
36+
TertiaryText,
3637

3738
/// <summary>
3839
/// Output demonstrating some kind of configuration issue, e.g. an invalid

src/Serilog.Sinks.Console/Sinks/SystemConsole/Themes/SystemConsoleThemes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static class SystemConsoleThemes
2424
{
2525
[ConsoleThemeStyle.Text] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.White },
2626
[ConsoleThemeStyle.SecondaryText] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.Gray },
27-
[ConsoleThemeStyle.Punctuation] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.DarkGray },
27+
[ConsoleThemeStyle.TertiaryText] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.DarkGray },
2828
[ConsoleThemeStyle.Invalid] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.Yellow },
2929
[ConsoleThemeStyle.Null] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.Blue },
3030
[ConsoleThemeStyle.Name] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.Gray },
@@ -45,7 +45,7 @@ static class SystemConsoleThemes
4545
{
4646
[ConsoleThemeStyle.Text] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.White },
4747
[ConsoleThemeStyle.SecondaryText] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.Gray },
48-
[ConsoleThemeStyle.Punctuation] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.DarkGray },
48+
[ConsoleThemeStyle.TertiaryText] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.DarkGray },
4949
[ConsoleThemeStyle.Invalid] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.White, Background = ConsoleColor.DarkGray},
5050
[ConsoleThemeStyle.Null] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.White },
5151
[ConsoleThemeStyle.Name] = new SystemConsoleThemeStyle { Foreground = ConsoleColor.Gray },

0 commit comments

Comments
 (0)