-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Ali-YousefiTelori/develop
Support for Logary, Loupe and Sentry new logging packages
- Loading branch information
Showing
27 changed files
with
596 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.0.0.5</Version> | ||
<Version>0.0.0.6</Version> | ||
<Description>logger wrapper</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>log,logger,logging,log4net</PackageTags> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.0.0.5</Version> | ||
<Version>0.0.0.6</Version> | ||
<Description>logger wrapper</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>log,logger,logging</PackageTags> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/CSharp/EasyMicroservices.Logger.Logary/EasyMicroservices.Logger.Logary.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Choose> | ||
<When Condition="$(SolutionFileName.Contains('Net7'))"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
</When> | ||
<Otherwise> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
</Otherwise> | ||
</Choose> | ||
|
||
<PropertyGroup> | ||
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.0.0.6</Version> | ||
<Description>logger wrapper</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>log,logger,logging,logary</PackageTags> | ||
<PackageProjectUrl>https://github.com/EasyMicroservices/Logger</PackageProjectUrl> | ||
<LangVersion>latest</LangVersion> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<DocumentationFile>.\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.Logger.Logary.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Logary" Version="5.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EasyMicroservices.Logger\EasyMicroservices.Logger.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
27 changes: 27 additions & 0 deletions
27
src/CSharp/EasyMicroservices.Logger.Logary/LogaryExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using EasyMicroservices.Logger.Logary.Providers; | ||
using EasyMicroservices.Logger.Options; | ||
using Logary; | ||
using System; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static class LogaryExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="options"></param> | ||
/// <param name="logger"></param> | ||
/// <returns></returns> | ||
public static LoggerOption UseLogary(this LoggerOption options, Logger logger) | ||
{ | ||
options.ThrowIfNull(nameof(options)); | ||
logger.ThrowIfNull(nameof(logger)); | ||
LoggerOptionBuilder.UseLogger(() => new LogaryProvider(logger)); | ||
return options; | ||
} | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
src/CSharp/EasyMicroservices.Logger.Logary/Providers/LogaryProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using EasyMicroservices.Logger.Providers; | ||
using EasyMicroservices.ServiceContracts; | ||
using Logary; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace EasyMicroservices.Logger.Logary.Providers; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class LogaryProvider : BaseProvider | ||
{ | ||
readonly global::Logary.Logger _logger; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="logger"></param> | ||
public LogaryProvider(global::Logary.Logger logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public LogaryProvider() | ||
{ | ||
_logger = global::Logary.Log.Create("Default"); | ||
} | ||
|
||
MessageContract Log(object[] args, LogLevel logLevel) | ||
{ | ||
var extracted = Extract(args); | ||
AddNotExistItems(extracted); | ||
var message = MessageModule.Event(logLevel, $"{extracted.Messages.First()}"); | ||
_logger.logWithAck(true, logLevel, Microsoft.FSharp.Core.FuncConvert.FromFunc<LogLevel, Message>((x) => message)); | ||
if (extracted.HasExceptions) | ||
{ | ||
var errormessage = MessageModule.Event(logLevel, $"{extracted.Exceptions.First()}"); | ||
_logger.logWithAck(true, logLevel, Microsoft.FSharp.Core.FuncConvert.FromFunc<LogLevel, Message>((x) => errormessage)); | ||
} | ||
|
||
return (MessageContract)true; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public override MessageContract Verbose(params object[] args) | ||
{ | ||
return Log(args, LogLevel.Verbose); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public override MessageContract Debug(params object[] args) | ||
{ | ||
return Log(args, LogLevel.Debug); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public override MessageContract Information(params object[] args) | ||
{ | ||
return Log(args, LogLevel.Info); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public override MessageContract Warning(params object[] args) | ||
{ | ||
return Log(args, LogLevel.Warn); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public override MessageContract Error(params object[] args) | ||
{ | ||
return Log(args, LogLevel.Error); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public override MessageContract Fatal(params object[] args) | ||
{ | ||
return Log(args, LogLevel.Fatal); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/CSharp/EasyMicroservices.Logger.Loupe/EasyMicroservices.Logger.Loupe.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Choose> | ||
<When Condition="$(SolutionFileName.Contains('Net7'))"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
</When> | ||
<Otherwise> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
</Otherwise> | ||
</Choose> | ||
|
||
<PropertyGroup> | ||
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.0.0.6</Version> | ||
<Description>logger wrapper</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>log,logger,logging,loupe</PackageTags> | ||
<PackageProjectUrl>https://github.com/EasyMicroservices/Logger</PackageProjectUrl> | ||
<LangVersion>latest</LangVersion> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<DocumentationFile>.\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.Logger.Loupe.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Loupe.Agent.Core" Version="5.0.0.14" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EasyMicroservices.Logger\EasyMicroservices.Logger.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
24 changes: 24 additions & 0 deletions
24
src/CSharp/EasyMicroservices.Logger.Loupe/LoupeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using EasyMicroservices.Logger.Loupe.Providers; | ||
using EasyMicroservices.Logger.Options; | ||
using System; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static class LoupeExtensions | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="options"></param> | ||
/// <returns></returns> | ||
public static LoggerOption UseLoupe(this LoggerOption options) | ||
{ | ||
options.ThrowIfNull(nameof(options)); | ||
LoggerOptionBuilder.UseLogger(() => new LoupeProvider()); | ||
return options; | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
src/CSharp/EasyMicroservices.Logger.Loupe/Providers/LoupeProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using EasyMicroservices.Logger.Providers; | ||
using EasyMicroservices.ServiceContracts; | ||
using Gibraltar.Agent; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace EasyMicroservices.Logger.Loupe.Providers; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class LoupeProvider : BaseProvider | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public LoupeProvider() | ||
{ | ||
|
||
} | ||
|
||
MessageContract InternalLog(object[] args, Action<string, object[]> action) | ||
{ | ||
var extracted = Extract(args); | ||
AddNotExistItems(extracted); | ||
action($"{extracted.Messages.First()}", null); | ||
if (extracted.HasExceptions) | ||
action($"{extracted.Exceptions.First()}", null); | ||
return (MessageContract)true; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public override MessageContract Verbose(params object[] args) | ||
{ | ||
return InternalLog(args, Log.TraceVerbose); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public override MessageContract Debug(params object[] args) | ||
{ | ||
return InternalLog(args, Log.TraceVerbose); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public override MessageContract Information(params object[] args) | ||
{ | ||
return InternalLog(args, Log.TraceInformation); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public override MessageContract Warning(params object[] args) | ||
{ | ||
return InternalLog(args, Log.TraceWarning); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public override MessageContract Error(params object[] args) | ||
{ | ||
return InternalLog(args, Log.TraceError); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="args"></param> | ||
/// <returns></returns> | ||
public override MessageContract Fatal(params object[] args) | ||
{ | ||
return InternalLog(args, Log.TraceCritical); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<Authors>EasyMicroservices</Authors> | ||
<IsPackable>true</IsPackable> | ||
<Version>0.0.0.5</Version> | ||
<Version>0.0.0.6</Version> | ||
<Description>logger wrapper</Description> | ||
<Copyright>[email protected]</Copyright> | ||
<PackageTags>log,logger,logging,nlog</PackageTags> | ||
|
Oops, something went wrong.