forked from NethermindEth/dotnet-libp2p
-
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.
feat(ping): NethermindEth#41 improve logging (NethermindEth#49)
- Loading branch information
Showing
2 changed files
with
122 additions
and
17 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,93 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: MIT | ||
|
||
using Microsoft.Extensions.Logging; | ||
using Nethermind.Libp2p.Core; | ||
|
||
namespace Nethermind.Libp2p.Protocols.Ping; | ||
|
||
internal static partial class LogMessages | ||
{ | ||
private const int EventId = 200_000; | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 1, | ||
EventName = nameof(ReadingPong), | ||
Message = "Reading pong {remotePeer}", | ||
Level = LogLevel.Trace)] | ||
internal static partial void ReadingPong( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 2, | ||
EventName = nameof(VerifyingPong), | ||
Message = "Verifying pong {remotePeer}", | ||
Level = LogLevel.Trace)] | ||
internal static partial void VerifyingPong( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 3, | ||
EventName = nameof(ReadingPing), | ||
Message = "Reading ping {remotePeer}", | ||
Level = LogLevel.Trace)] | ||
internal static partial void ReadingPing( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 4, | ||
EventName = nameof(ReturningPong), | ||
Message = "Returning pong {remotePeer}", | ||
Level = LogLevel.Trace)] | ||
internal static partial void ReturningPong( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 5, | ||
EventName = nameof(LogPing), | ||
Message = "Ping {remotePeer}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void LogPing( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 6, | ||
EventName = nameof(LogPinged), | ||
Message = "Pinged {remotePeer}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void LogPinged( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 7, | ||
EventName = nameof(PingListenStarted), | ||
Message = "Ping listen started from {remotePeer}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void PingListenStarted( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 8, | ||
EventName = nameof(PingFinished), | ||
Message = "Ping finished {remotePeer}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void PingFinished( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
|
||
[LoggerMessage( | ||
EventId = EventId + 9, | ||
EventName = nameof(PingFailed), | ||
Message = "Wrong response to ping from {remotePeer}", | ||
Level = LogLevel.Warning)] | ||
internal static partial void PingFailed( | ||
this ILogger logger, | ||
Multiaddr remotePeer); | ||
} |
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