mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-27 15:45:06 +03:00
Log with caller (#9976)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace ServiceLib.Common;
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
@@ -138,7 +139,10 @@ public static class Extension
|
|||||||
public static async Task<TOutput> HandleSafe<TInput, TOutput>(
|
public static async Task<TOutput> HandleSafe<TInput, TOutput>(
|
||||||
this Interaction<TInput, TOutput> interaction,
|
this Interaction<TInput, TOutput> interaction,
|
||||||
TInput input,
|
TInput input,
|
||||||
TOutput defaultValue = default!)
|
TOutput defaultValue = default!,
|
||||||
|
[CallerMemberName] string memberName = "",
|
||||||
|
[CallerFilePath] string filePath = "",
|
||||||
|
[CallerLineNumber] int lineNumber = 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -146,12 +150,14 @@ public static class Extension
|
|||||||
}
|
}
|
||||||
catch (UnhandledInteractionException<TInput, TOutput> ex)
|
catch (UnhandledInteractionException<TInput, TOutput> ex)
|
||||||
{
|
{
|
||||||
Logging.SaveLog($"Unhandled interaction exception for input: {input}", ex);
|
var title = $"Unhandled interaction exception in {memberName} at {filePath}:{lineNumber}";
|
||||||
|
Logging.SaveLog(title, ex);
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logging.SaveLog($"Exception occurred while handling interaction for input: {input}", ex);
|
var title = $"Exception occurred while handling interaction in {memberName} at {filePath}:{lineNumber}, input: {input}";
|
||||||
|
Logging.SaveLog(title, ex);
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user