Add project files.

This commit is contained in:
2025-07-29 12:48:00 -06:00
commit c3dc123527
21 changed files with 1231 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using System.Collections.Generic;
namespace Serilog.Sinks.LogEmAll
{
/// <summary>
/// ListStringLog class
/// </summary>
public partial class ListStringLog : List<string>
{
#region Constructors
/// <summary>
/// Constructor
/// </summary>
public ListStringLog()
{
ListStringLogSink.ListStringSink.OnLogReceived += ListStringSinkOnLogReceived;
}
#endregion
#region ListStringSink
/// <summary>
/// Outputs a text string to the List String Sink log.
/// </summary>
/// <param name="strMsg"></param>
private void ListStringSinkOnLogReceived(string strMsg)
{
// Add the line of text to the log.
this.Add(strMsg);
}
#endregion
}
}

View File

@@ -0,0 +1,22 @@
using Serilog;
using Serilog.Formatting;
namespace Serilog.Sinks.LogEmAll
{
/// <summary>
/// ListStringLogExtensions class
/// </summary>
public static class ListStringLogExtensions
{
/// <summary>
/// Write the simple formatted text logs directly to the List String. This List String control can be used from the toolbox.
/// </summary>
/// <param name="configuration"></param>
/// <param name="formatter"></param>
/// <returns></returns>
public static LoggerConfiguration WriteToListString(this LoggerConfiguration configuration, ITextFormatter formatter = null)
{
return configuration.WriteTo.Sink(ListStringLogSink.MakeListStringSink(formatter));
}
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.IO;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Display;
namespace Serilog.Sinks.LogEmAll
{
/// <summary>
/// ListStringLogInternal class
/// </summary>
public class ListStringLogInternal : ILogEventSink
{
/// Private member variable
private ITextFormatter _textFormatter;
///
public delegate void LogHandler(string str);
///
public event LogHandler OnLogReceived;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textFormatter"></param>
public ListStringLogInternal(ITextFormatter textFormatter)
{
_textFormatter = textFormatter;
}
/// <summary>
/// Emit
/// </summary>
/// <param name="logEvent"></param>
public void Emit(LogEvent logEvent)
{
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
if (_textFormatter == null) { throw new ArgumentNullException("Missing Log Formatter"); }
var renderSpace = new StringWriter();
_textFormatter.Format(logEvent, renderSpace);
FireEvent(renderSpace.ToString());
}
/// <summary>
/// Fire Event
/// </summary>
/// <param name="str"></param>
private void FireEvent(string str)
{
OnLogReceived?.Invoke(str);
}
}
/// <summary>
/// ListStringLogSink class.
/// </summary>
public static class ListStringLogSink
{
///
private static ListStringLogInternal _listStringSink = new ListStringLogInternal(new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message} {Exception}"));
///
public static ListStringLogInternal ListStringSink => _listStringSink;
/// <summary>
/// MakeListStringSink
/// </summary>
/// <param name="formatter"></param>
/// <returns></returns>
public static ListStringLogInternal MakeListStringSink(ITextFormatter formatter = null)
{
if (formatter == null) { formatter = new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message} {Exception}"); }
_listStringSink = new ListStringLogInternal(formatter);
return _listStringSink;
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Serilog.Sinks.LogEmAll")]
[assembly: AssemblyDescription("The Original LogEmAll Logger")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("LogEmAll")]
[assembly: AssemblyProduct("Serilog.Sinks.LogEmAll")]
[assembly: AssemblyCopyright("Copyright (c) 2020-2025 LogEmAll - All Rights Reserved")]
[assembly: AssemblyTrademark("LogEmAll - The Original LogEmAll Logger")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1ef874f5-0837-444b-a8ee-3862eb936bcb")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.8")]
[assembly: AssemblyFileVersion("0.0.8")]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,37 @@

namespace Serilog.Sinks.LogEmAll
{
partial class RichTextBoxLog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@@ -0,0 +1,51 @@
using System.Windows.Forms;
namespace Serilog.Sinks.LogEmAll
{
/// <summary>
/// RichTextBoxLog class
/// </summary>
public partial class RichTextBoxLog : RichTextBox
{
#region Constructors
/// <summary>
/// Constructor
/// </summary>
public RichTextBoxLog()
{
InitializeComponent();
RichTextBoxLogSink.RichTextBoxSink.OnLogReceived += RichTextBoxSinkOnLogReceived;
}
#endregion
#region RichTextBoxSink
/// <summary>
/// Outputs a text string to the RichTextBox Sink log.
/// </summary>
/// <param name="strMsg"></param>
private void RichTextBoxSinkOnLogReceived(string strMsg)
{
if (this.InvokeRequired)
{
this.Invoke(
(MethodInvoker)delegate
{
this.AppendText(strMsg);
this.ScrollToCaret();
});
}
else
{
this.AppendText(strMsg);
this.ScrollToCaret();
}
Application.DoEvents();
}
#endregion
}
}

View File

@@ -0,0 +1,22 @@
using Serilog;
using Serilog.Formatting;
namespace Serilog.Sinks.LogEmAll
{
/// <summary>
/// RichTextBoxSinkExtensions class
/// </summary>
public static class RichTextBoxSinkExtensions
{
/// <summary>
/// Write the simple formatted text logs directly to the RichTextBox. This simple RichTextBox control can be used from the toolbox.
/// </summary>
/// <param name="configuration"></param>
/// <param name="formatter"></param>
/// <returns></returns>
public static LoggerConfiguration WriteToRichTextBox(this LoggerConfiguration configuration, ITextFormatter formatter = null)
{
return configuration.WriteTo.Sink(RichTextBoxLogSink.MakeRichTextBoxSink(formatter));
}
}
}

View File

@@ -0,0 +1,83 @@
using System;
using System.IO;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Display;
namespace Serilog.Sinks.LogEmAll
{
/// <summary>
/// RichTextBoxLogInternal class
/// </summary>
public class RichTextBoxLogInternal : ILogEventSink
{
/// Private member variable
private ITextFormatter _textFormatter;
///
public delegate void LogHandler(string str);
///
public event LogHandler OnLogReceived;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textFormatter"></param>
public RichTextBoxLogInternal(ITextFormatter textFormatter)
{
_textFormatter = textFormatter;
}
/// <summary>
/// Emit
/// </summary>
/// <param name="logEvent"></param>
public void Emit(LogEvent logEvent)
{
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
if (_textFormatter == null) { throw new ArgumentNullException("Missing Log Formatter"); }
var renderSpace = new StringWriter();
_textFormatter.Format(logEvent, renderSpace);
FireEvent(renderSpace.ToString());
}
/// <summary>
/// Fire Event
/// </summary>
/// <param name="str"></param>
private void FireEvent(string str)
{
OnLogReceived?.Invoke(str);
}
}
/// <summary>
/// RichTextBoxLogSink class.
/// </summary>
public static class RichTextBoxLogSink
{
///
private static RichTextBoxLogInternal _richTextBoxSink = new RichTextBoxLogInternal(new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message} {Exception}"));
///
public static RichTextBoxLogInternal RichTextBoxSink => _richTextBoxSink;
/// <summary>
/// MakeRichTextBoxSink
/// </summary>
/// <param name="formatter"></param>
/// <returns></returns>
public static RichTextBoxLogInternal MakeRichTextBoxSink(ITextFormatter formatter = null)
{
if (formatter == null) { formatter = new MessageTemplateTextFormatter("{Timestamp} [{Level}] {Message} {Exception}"); }
_richTextBoxSink = new RichTextBoxLogInternal(formatter);
return _richTextBoxSink;
}
}
}

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1EF874F5-0837-444B-A8EE-3862EB936BCB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Serilog.Sinks.LogEmAll</RootNamespace>
<AssemblyName>Serilog.Sinks.LogEmAll</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\Serilog.Sinks.LogEmAll.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Serilog.Sinks.LogEmAll.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>
</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.12.0\lib\net46\Serilog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ListStringLog.cs" />
<Compile Include="ListStringLogExtensions.cs" />
<Compile Include="ListStringLogInternal.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RichTextBoxLog.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="RichTextBoxLog.Designer.cs">
<DependentUpon>RichTextBoxLog.cs</DependentUpon>
</Compile>
<Compile Include="RichTextBoxLogExtensions.cs" />
<Compile Include="RichTextBoxLogInternal.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Serilog.Sinks.LogEmAll.nuspec" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Resources\icon.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>nuget pack "$(ProjectPath)" -Prop Configuration=$(ConfigurationName)
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>Serilog.Sinks.LogEmAll</id>
<title>Serilog.Sinks.LogEmAll</title>
<version>0.0.8</version>
<description>Use the LogEmAll Library (.dll) to write Serilog events to a List&lt;String&gt; or a Windows Forms Application RichTextBox control from anywhere in your application.
Install or add the LogEmAll Nuget Package to your application by downloading the [nuget.nupkg](https://gitemall.devemall.int.eu.org/TommySalami/Serilog.Sinks.LogEmAll/packages) to your project folder and opening a Nuget Package Manager Console in Visual Studio and type:
```
Install-Package nuget.nupkg
```
</description>
<authors>LogEmAll</authors>
<license type="file">LICENSE</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<icon>icon.png</icon>
<iconUrl>https://gitemall.devemall.int.eu.org/TommySalami/Serilog.Sinks.LogEmAll/src/branch/master/Serilog.Sinks.LogEmAll/Resources/Icon.png</iconUrl>
<projectUrl>https://gitemall.devemall.int.eu.org/TommySalami/Serilog.Sinks.LogEmAll</projectUrl>
<releaseNotes>See https://gitemall.devemall.int.eu.org/TommySalami/Serilog.Sinks.LogEmAll/releases for release notes.</releaseNotes>
<copyright>Copyright (c) 2016-2025 LogEmAll - All Rights Reserved</copyright>
<tags>Serilog Sinks LogEmAll Sink Logs Log WinForms SerilogSink SerilogSinksLogEmAll Windows Forms Application Console RichTextBox RichTextBoxLog ListStringLog Logger</tags>
<repository type="git" url="https://gitemall.devemall.int.eu.org/TommySalami/Serilog.Sinks.LogEmAll.git" />
</metadata>
<files>
<file src="..\LICENSE" target="LICENSE" />
<file src="Resources\icon.png" target="icon.png" />
</files>
</package>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Serilog" version="2.12.0" targetFramework="net461" />
</packages>