Skip to content

Commit 41ed0e1

Browse files
author
umair.hussein
committed
fix ForContext
1 parent 576ed00 commit 41ed0e1

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

src/Sample/TestApplication/Form1.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ namespace TestApplication
1414
{
1515
public partial class Form1 : Form
1616
{
17+
private ILogger logger = Log.ForContext<Form1>();
1718
public Form1()
1819
{
1920
InitializeComponent();
20-
Log.Information("Form1 has been Initialized");
21+
logger.Information("Form1 has been Initialized");
2122
}
2223

2324
private void button1_Click(object sender, EventArgs e)
2425
{
25-
Log.Information(textBox1.Text);
26+
logger.Information(textBox1.Text);
2627
}
2728
}
2829
}

src/Sample/TestApplication/LogVieweer.Designer.cs

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Serilog.Sinks.WinForms.Core/RichTextBoxLogControl.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace Serilog.Sinks.WinForms.Core
55
public partial class RichTextBoxLogControl : RichTextBox
66
{
77
public string ForContext { get; set; } = string.Empty;
8-
private bool _isContextConfigured = false;
98

109
public RichTextBoxLogControl()
1110
{
@@ -20,10 +19,9 @@ public RichTextBoxLogControl()
2019

2120
private void SimpleTextBoxSinkOnLogReceived(string context, string str)
2221
{
23-
if (_isContextConfigured)
22+
if (!string.IsNullOrEmpty(this.ForContext.Trim()))
2423
{
25-
if (!string.IsNullOrEmpty(this.ForContext)
26-
&& !string.IsNullOrEmpty(context)
24+
if (!string.IsNullOrEmpty(context)
2725
&& this.ForContext.Equals(context, StringComparison.InvariantCultureIgnoreCase)) { PrintText(str); }
2826
}
2927
else

src/Serilog.Sinks.WinForms.Net/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("2.4.2.0")]
37-
[assembly: AssemblyFileVersion("2.4.2.0")]
36+
[assembly: AssemblyVersion("2.4.3.0")]
37+
[assembly: AssemblyFileVersion("2.4.3.0")]
3838
[assembly: NeutralResourcesLanguage("en")]

src/Serilog.Sinks.WinForms.Net/RichTextBoxLogControl.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace Serilog.Sinks.WinForms
77
public partial class RichTextBoxLogControl : RichTextBox
88
{
99
public string ForContext { get; set; } = string.Empty;
10-
private bool _isContextConfigured = false;
1110

1211
public RichTextBoxLogControl()
1312
{
1413
InitializeComponent();
14+
1515
WindFormsSink.SimpleTextBoxSink.OnLogReceived += SimpleTextBoxSinkOnLogReceived;
1616

1717
HandleDestroyed += ( sender, args ) =>
@@ -22,10 +22,9 @@ public RichTextBoxLogControl()
2222

2323
private void SimpleTextBoxSinkOnLogReceived(string context, string str)
2424
{
25-
if (_isContextConfigured)
25+
if (!string.IsNullOrEmpty(this.ForContext.Trim()))
2626
{
27-
if (!string.IsNullOrEmpty(this.ForContext)
28-
&& !string.IsNullOrEmpty(context)
27+
if (!string.IsNullOrEmpty(context)
2928
&& this.ForContext.Equals(context, StringComparison.InvariantCultureIgnoreCase)) { PrintText(str); }
3029
}
3130
else

src/Serilog.Sinks.WinForms.sln

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.WinForms.Core
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.WinForms.Base", "Serilog.Sinks.WinForms.Base\Serilog.Sinks.WinForms.Base.csproj", "{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplicationNet6", "Sample\TestApplicationNet6\TestApplicationNet6.csproj", "{13CBCDA2-8B30-4F01-AAB1-6D749DD77B67}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplicationNet6", "Sample\TestApplicationNet6\TestApplicationNet6.csproj", "{13CBCDA2-8B30-4F01-AAB1-6D749DD77B67}"
2121
EndProject
2222
Global
2323
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -45,8 +45,8 @@ Global
4545
{B1CC4152-652E-42FE-87D3-E9BC5AC5BB7C}.Debug|Any CPU.Build.0 = Release|Any CPU
4646
{B1CC4152-652E-42FE-87D3-E9BC5AC5BB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
4747
{B1CC4152-652E-42FE-87D3-E9BC5AC5BB7C}.Release|Any CPU.Build.0 = Release|Any CPU
48-
{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49-
{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}.Debug|Any CPU.ActiveCfg = Release|Any CPU
49+
{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}.Debug|Any CPU.Build.0 = Release|Any CPU
5050
{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}.Release|Any CPU.ActiveCfg = Release|Any CPU
5151
{CCB237EE-BC54-435F-A0F2-0C13CBCF6E06}.Release|Any CPU.Build.0 = Release|Any CPU
5252
{13CBCDA2-8B30-4F01-AAB1-6D749DD77B67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

0 commit comments

Comments
 (0)