Finalized logger
Added Console Demo
This commit is contained in:
parent
8add6b467d
commit
dd5fc290b2
6
SweetLib.Demo.Console/App.config
Normal file
6
SweetLib.Demo.Console/App.config
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
26
SweetLib.Demo.Console/Program.cs
Normal file
26
SweetLib.Demo.Console/Program.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SweetLib.Utils.Logger;
|
||||||
|
|
||||||
|
namespace SweetLib.Demo.Console
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
//Logger.GlobalLogLevel |= LogLevel.Debug | LogLevel.Trace;
|
||||||
|
Logger.GlobalLogLevel=LogLevel.All;
|
||||||
|
|
||||||
|
Logger.Trace("Trace!");
|
||||||
|
Logger.Debug("Debug");
|
||||||
|
Logger.Info("Hallo Welt");
|
||||||
|
Logger.Warn("WARN!");
|
||||||
|
Logger.Error("Error :(");
|
||||||
|
|
||||||
|
System.Console.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
SweetLib.Demo.Console/Properties/AssemblyInfo.cs
Normal file
36
SweetLib.Demo.Console/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
|
// die einer Assembly zugeordnet sind.
|
||||||
|
[assembly: AssemblyTitle("SweetLib.Demo.Console")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("SweetLib.Demo.Console")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
||||||
|
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
|
||||||
|
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||||
|
[assembly: Guid("c8681e08-6f23-45e1-a16f-bba72003219b")]
|
||||||
|
|
||||||
|
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||||
|
//
|
||||||
|
// Hauptversion
|
||||||
|
// Nebenversion
|
||||||
|
// Buildnummer
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.19.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.19.0")]
|
66
SweetLib.Demo.Console/SweetLib.Demo.Console.csproj
Normal file
66
SweetLib.Demo.Console/SweetLib.Demo.Console.csproj
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{C8681E08-6F23-45E1-A16F-BBA72003219B}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>SweetLib.Demo.Console</RootNamespace>
|
||||||
|
<AssemblyName>SweetLib.Demo.Console</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<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="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SweetLib\SweetLib.csproj">
|
||||||
|
<Project>{02c1f8ef-32f2-4e77-a36d-79129402af37}</Project>
|
||||||
|
<Name>SweetLib</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.12.0")]
|
[assembly: AssemblyVersion("1.0.13.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.12.0")]
|
[assembly: AssemblyFileVersion("1.0.13.0")]
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.25123.0
|
VisualStudioVersion = 14.0.25420.1
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweetLib", "SweetLib\SweetLib.csproj", "{02C1F8EF-32F2-4E77-A36D-79129402AF37}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweetLib", "SweetLib\SweetLib.csproj", "{02C1F8EF-32F2-4E77-A36D-79129402AF37}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweetLib.Demo", "SweetLib.Demo\SweetLib.Demo.csproj", "{9350E0D4-9FE7-49D5-ACDE-E857E547889C}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweetLib.Demo", "SweetLib.Demo\SweetLib.Demo.csproj", "{9350E0D4-9FE7-49D5-ACDE-E857E547889C}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweetLib.Demo.Console", "SweetLib.Demo.Console\SweetLib.Demo.Console.csproj", "{C8681E08-6F23-45E1-A16F-BBA72003219B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -21,6 +23,10 @@ Global
|
||||||
{9350E0D4-9FE7-49D5-ACDE-E857E547889C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9350E0D4-9FE7-49D5-ACDE-E857E547889C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9350E0D4-9FE7-49D5-ACDE-E857E547889C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9350E0D4-9FE7-49D5-ACDE-E857E547889C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9350E0D4-9FE7-49D5-ACDE-E857E547889C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9350E0D4-9FE7-49D5-ACDE-E857E547889C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C8681E08-6F23-45E1-A16F-BBA72003219B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C8681E08-6F23-45E1-A16F-BBA72003219B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C8681E08-6F23-45E1-A16F-BBA72003219B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C8681E08-6F23-45E1-A16F-BBA72003219B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
@ -32,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.3.0")]
|
[assembly: AssemblyVersion("1.0.21.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.3.0")]
|
[assembly: AssemblyFileVersion("1.0.21.0")]
|
||||||
|
|
|
@ -12,7 +12,9 @@ namespace SweetLib.Utils.Logger
|
||||||
Debug = 1 << 1,
|
Debug = 1 << 1,
|
||||||
Info = 1 << 2,
|
Info = 1 << 2,
|
||||||
Warn = 1 << 3,
|
Warn = 1 << 3,
|
||||||
Error = 1 << 4
|
Error = 1 << 4,
|
||||||
|
|
||||||
|
All = Int32.MaxValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static class Logger
|
public static class Logger
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SweetLib.Utils.Logger.Message;
|
using SweetLib.Utils.Logger.Message;
|
||||||
|
|
||||||
namespace SweetLib.Utils.Logger.Memory
|
namespace SweetLib.Utils.Logger.Memory
|
||||||
|
@ -107,6 +106,9 @@ namespace SweetLib.Utils.Logger.Memory
|
||||||
|
|
||||||
using (var tmpFileStream = new FileInfo(TempFile).OpenRead())
|
using (var tmpFileStream = new FileInfo(TempFile).OpenRead())
|
||||||
{
|
{
|
||||||
|
if (!Directory.Exists(Path.GetDirectoryName(fullFileName)))
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(fullFileName));
|
||||||
|
|
||||||
using (var compressedFileStream = File.Create(fullFileName))
|
using (var compressedFileStream = File.Create(fullFileName))
|
||||||
{
|
{
|
||||||
using (var compressionsStream = new GZipStream(compressedFileStream, CompressionMode.Compress))
|
using (var compressionsStream = new GZipStream(compressedFileStream, CompressionMode.Compress))
|
||||||
|
@ -130,7 +132,19 @@ namespace SweetLib.Utils.Logger.Memory
|
||||||
ProcessQueue();
|
ProcessQueue();
|
||||||
|
|
||||||
if (AutoArchiveOnDispose)
|
if (AutoArchiveOnDispose)
|
||||||
Archive();
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Archive();
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Delete(TempFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace SweetLib.Utils.Logger.Message
|
||||||
|
|
||||||
public static LogMessageFormatter FormatterInstance { get; set; }
|
public static LogMessageFormatter FormatterInstance { get; set; }
|
||||||
|
|
||||||
public static string DefaultFormatString { get; set; } = $"[{CultureInfo.CurrentCulture.DateTimeFormat}] (LL) - V";
|
public static string DefaultFormatString { get; set; } = $"[{CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern} - {CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern}] (LL): V";
|
||||||
|
|
||||||
public static LogMessageFormatter Instance
|
public static LogMessageFormatter Instance
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetLib.Utils.TaskBar
|
namespace SweetLib.Utils.TaskBar
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue