-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): log transactions received from Nordigen
- Loading branch information
1 parent
d0d072b
commit a0b98d8
Showing
3 changed files
with
54 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2021 Valters Melnalksnis | ||
// Licensed under the GNU Affero General Public License v3.0 or later. | ||
// See LICENSE.txt file in the project root for full license information. | ||
|
||
using System.Text.Json; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
using VMelnalksnis.NordigenDotNet.Accounts; | ||
|
||
using static Microsoft.Extensions.Logging.LogLevel; | ||
|
||
namespace Gnomeshade.WebApi.Logging; | ||
|
||
/// <summary>Helper methods for logging.</summary> | ||
internal static partial class LoggerExtensions | ||
{ | ||
[LoggerMessage(1, Debug, "Getting requisition for {InstitutionId}")] | ||
internal static partial void GettingRequisition(this ILogger logger, string institutionId); | ||
|
||
[LoggerMessage(2, Debug, "Creating new requisition for {InstitutionId}")] | ||
internal static partial void CreatingRequisition(this ILogger logger, string institutionId); | ||
|
||
[LoggerMessage(3, Debug, "Matched report account to {AccountName}")] | ||
internal static partial void MatchedReportAccount(this ILogger logger, string accountName); | ||
|
||
[LoggerMessage(4, Trace, "Parsing transaction {ServicerReference}; {BookedTransaction}")] | ||
internal static partial void ParsingTransaction(this ILogger logger, string servicerReference, string bookedTransaction); | ||
|
||
internal static void ParsingTransaction(this ILogger logger, BookedTransaction transaction) | ||
{ | ||
var json = JsonSerializer.Serialize(transaction, LoggingSerializerContext.Default.BookedTransaction); | ||
logger.ParsingTransaction(transaction.TransactionId, json); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
source/Gnomeshade.WebApi/Logging/LoggingSerializerContext.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,14 @@ | ||
// Copyright 2021 Valters Melnalksnis | ||
// Licensed under the GNU Affero General Public License v3.0 or later. | ||
// See LICENSE.txt file in the project root for full license information. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
using VMelnalksnis.NordigenDotNet.Accounts; | ||
|
||
namespace Gnomeshade.WebApi.Logging; | ||
|
||
/// <inheritdoc cref="JsonSerializerContext" /> | ||
[JsonSourceGenerationOptions(IgnoreReadOnlyProperties = true)] | ||
[JsonSerializable(typeof(BookedTransaction))] | ||
internal sealed partial class LoggingSerializerContext : JsonSerializerContext; |
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