Compare commits
No commits in common. "d6356451ac7826881f518b27739ce6e9c9860a22" and "5b2044a160da4c8ecb1744ae1c668a90d47f5486" have entirely different histories.
d6356451ac
...
5b2044a160
|
|
@ -10,6 +10,10 @@
|
||||||
<ProjectReference Include="..\AyCode.Utils\AyCode.Utils.csproj" />
|
<ProjectReference Include="..\AyCode.Utils\AyCode.Utils.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Extensions\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
using AyCode.Utils.Extensions;
|
|
||||||
|
|
||||||
namespace AyCode.Core.Extensions;
|
|
||||||
|
|
||||||
public static class ExceptionExtensions
|
|
||||||
{
|
|
||||||
public static void GetCategoryAndMemberNameFromStackTraceString(this Exception? exception, out string? memberName, out string? categoryName)
|
|
||||||
{
|
|
||||||
categoryName = null;
|
|
||||||
memberName = null;
|
|
||||||
|
|
||||||
if (exception == null) return;
|
|
||||||
|
|
||||||
var stackTraceString = exception.StackTrace ?? exception.InnerException?.StackTrace;
|
|
||||||
if (stackTraceString.IsNullOrWhiteSpace()) return;
|
|
||||||
|
|
||||||
var stackSplit = stackTraceString.Split(" in ");
|
|
||||||
if (stackSplit.Length <= 0) return;
|
|
||||||
|
|
||||||
stackSplit = stackSplit[0].Split('.');
|
|
||||||
if (stackSplit.Length <= 1) return;
|
|
||||||
|
|
||||||
memberName = stackSplit[^1]; //new StackTrace(exception).GetFrame(0)?.GetMethod()?.Name;
|
|
||||||
categoryName = stackSplit[^2]; //exception.Source
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,8 +9,6 @@ public interface IAcConsoleLogWriter : IAcTextLogWriterBase
|
||||||
|
|
||||||
public class AcConsoleLogWriter : AcTextLogWriterBase, IAcConsoleLogWriter
|
public class AcConsoleLogWriter : AcTextLogWriterBase, IAcConsoleLogWriter
|
||||||
{
|
{
|
||||||
private static readonly object ForWriterLock = new();
|
|
||||||
|
|
||||||
protected AcConsoleLogWriter() : this(null)
|
protected AcConsoleLogWriter() : this(null)
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
@ -35,25 +33,29 @@ public class AcConsoleLogWriter : AcTextLogWriterBase, IAcConsoleLogWriter
|
||||||
{
|
{
|
||||||
if (logText.IsNullOrWhiteSpace()) return;
|
if (logText.IsNullOrWhiteSpace()) return;
|
||||||
|
|
||||||
lock (ForWriterLock)
|
//lock (ForWriterLock)
|
||||||
{
|
{
|
||||||
switch (loglevel)
|
if (loglevel is > LogLevel.Trace and < LogLevel.Suggest)
|
||||||
{
|
{
|
||||||
case > LogLevel.Trace and < LogLevel.Suggest:
|
//Console.ForegroundColor = ConsoleColor.White;
|
||||||
Console.WriteLine(logText);
|
Console.WriteLine(logText);
|
||||||
return;
|
return;
|
||||||
case <= LogLevel.Trace:
|
}
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
|
||||||
Console.WriteLine(logText);
|
if (loglevel <= LogLevel.Trace)
|
||||||
break;
|
{
|
||||||
case LogLevel.Suggest:
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
Console.WriteLine(logText);
|
||||||
Console.WriteLine(logText);
|
}
|
||||||
break;
|
else if (loglevel == LogLevel.Suggest)
|
||||||
default:
|
{
|
||||||
Console.ForegroundColor = loglevel == LogLevel.Warning ? ConsoleColor.Yellow : ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||||
Console.WriteLine($"{AcEnv.NL}{logText}{AcEnv.NL}");
|
Console.WriteLine(logText);
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = loglevel == LogLevel.Warning ? ConsoleColor.Yellow : ConsoleColor.Red;
|
||||||
|
Console.WriteLine($"{AcEnv.NL}{logText}{AcEnv.NL}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue