-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce ModuleLoggerAspectAttribute & ServiceLoggerAspectAttribute
- Loading branch information
Showing
10 changed files
with
82 additions
and
15 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
21 changes: 21 additions & 0 deletions
21
SRC/RPC.Interfaces/Attributes/Aspects/Logging/ModuleLoggerAspectAttribute.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,21 @@ | ||
/******************************************************************************** | ||
* ModuleLoggerAspectAttribute.cs * | ||
* * | ||
* Author: Denes Solti * | ||
********************************************************************************/ | ||
using System; | ||
|
||
namespace Solti.Utils.Rpc.Interfaces | ||
{ | ||
/// <summary> | ||
/// Marks a module to be logged. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false)] | ||
public sealed class ModuleLoggerAspectAttribute: LoggerAspectAttribute | ||
{ | ||
/// <summary> | ||
/// Creates a new <see cref="ModuleLoggerAspectAttribute"/> instance. | ||
/// </summary> | ||
public ModuleLoggerAspectAttribute() : base(typeof(ModuleMethodScopeLogger), typeof(ExceptionLogger), typeof(ParameterLogger), typeof(StopWatchLogger)) { } | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
SRC/RPC.Interfaces/Attributes/Aspects/Logging/ServiceLoggerAspectAttribute.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,21 @@ | ||
/******************************************************************************** | ||
* ServiceLoggerAspectAttribute.cs * | ||
* * | ||
* Author: Denes Solti * | ||
********************************************************************************/ | ||
using System; | ||
|
||
namespace Solti.Utils.Rpc.Interfaces | ||
{ | ||
/// <summary> | ||
/// Marks a service to be logged. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Interface, AllowMultiple = false)] | ||
public sealed class ServiceLoggerAspectAttribute: LoggerAspectAttribute | ||
{ | ||
/// <summary> | ||
/// Creates a new <see cref="ServiceLoggerAspectAttribute"/> instance. | ||
/// </summary> | ||
public ServiceLoggerAspectAttribute() : base(typeof(ServiceMethodScopeLogger), typeof(ExceptionLogger), typeof(ParameterLogger)) { } | ||
} | ||
} |
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
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
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
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,29 @@ | ||
/******************************************************************************** | ||
* ServiceMethodScopeLogger.cs * | ||
* * | ||
* Author: Denes Solti * | ||
********************************************************************************/ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Solti.Utils.Rpc.Interfaces | ||
{ | ||
/// <summary> | ||
/// Creates a new log scope containing the service and method name. | ||
/// </summary> | ||
public sealed class ServiceMethodScopeLogger: LoggerBase | ||
{ | ||
/// <inheritdoc/> | ||
public override object? Invoke(LogContext context, Func<object?> callNext) | ||
{ | ||
using IDisposable? logScope = context.Logger.BeginScope(new Dictionary<string, object> | ||
{ | ||
["Service"] = context.Method.ReflectedType, | ||
["Method"] = context.Method | ||
// TODO: szerviz nev | ||
}); | ||
|
||
return callNext(); | ||
} | ||
} | ||
} |
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
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
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