Skip to content

Commit

Permalink
feat(core): #41 add event ids (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
chertby authored Oct 23, 2023
1 parent d7e6415 commit 4072231
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/libp2p/Libp2p.Core/LogMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,38 @@ namespace Nethermind.Libp2p.Core;

internal static partial class LogMessages
{
private const int EventId = 101_000;

[LoggerMessage(
EventId = EventId + 1,
EventName = nameof(ReadChunk),
Message = "Read chunk {bytes} bytes",
Level = LogLevel.Trace)]
internal static partial void ReadChunk(
this ILogger logger,
long bytes);

[LoggerMessage(
EventId = EventId + 2,
EventName = nameof(ReadEnough),
Message = "Read enough {bytes} bytes",
Level = LogLevel.Trace)]
internal static partial void ReadEnough(
this ILogger logger,
long bytes);

[LoggerMessage(
EventId = EventId + 3,
EventName = nameof(WriteBytes),
Message = "Write {bytes} bytes",
Level = LogLevel.Trace)]
internal static partial void WriteBytes(
this ILogger logger,
long bytes);

[LoggerMessage(
EventId = EventId + 4,
EventName = nameof(DialStarted),
Message = "Dial {channel} on protocol {protocol} with sub-protocols {subProtocols}",
Level = LogLevel.Debug)]
internal static partial void DialStarted(
Expand All @@ -38,6 +48,8 @@ internal static partial void DialStarted(
IEnumerable<string> subProtocols);

[LoggerMessage(
EventId = EventId + 5,
EventName = nameof(ListenStarted),
Message = "Listen {channel} on protocol {protocol} with sub-protocols {subProtocols}",
Level = LogLevel.Debug)]
internal static partial void ListenStarted(
Expand All @@ -47,6 +59,8 @@ internal static partial void ListenStarted(
IEnumerable<string> subProtocols);

[LoggerMessage(
EventId = EventId + 6,
EventName = nameof(DialAndBindStarted),
Message = "Dial and bind {channel} on protocol {protocol} with sub-protocols {subProtocols}",
Level = LogLevel.Debug)]
internal static partial void DialAndBindStarted(
Expand All @@ -56,6 +70,8 @@ internal static partial void DialAndBindStarted(
IEnumerable<string> subProtocols);

[LoggerMessage(
EventId = EventId + 7,
EventName = nameof(ListenAndBindStarted),
Message = "Listen and bind {channel} on protocol {protocol} with sub-protocols {subProtocols}",
Level = LogLevel.Debug)]
internal static partial void ListenAndBindStarted(
Expand All @@ -65,13 +81,17 @@ internal static partial void ListenAndBindStarted(
IEnumerable<string> subProtocols);

[LoggerMessage(
EventId = EventId + 8,
EventName = nameof(ChannelCreated),
Message = "Create channel {chan}",
Level = LogLevel.Debug)]
internal static partial void ChannelCreated(
this ILogger logger,
string chan);

[LoggerMessage(
EventId = EventId + 9,
EventName = nameof(DialFailed),
Message = "Dial error {protocol} via {channel}: {errorMessage}",
Level = LogLevel.Error,
SkipEnabledCheck = true)]
Expand All @@ -83,6 +103,8 @@ internal static partial void DialFailed(
string errorMessage);

[LoggerMessage(
EventId = EventId + 10,
EventName = nameof(ListenFailed),
Message = "Listen error {protocol} via {channel}: {errorMessage}",
Level = LogLevel.Error,
SkipEnabledCheck = true)]
Expand All @@ -94,6 +116,8 @@ internal static partial void ListenFailed(
string errorMessage);

[LoggerMessage(
EventId = EventId + 11,
EventName = nameof(DialAndBindFailed),
Message = "Dial and bind error {protocol} via {channel}: {errorMessage}",
Level = LogLevel.Error,
SkipEnabledCheck = true)]
Expand All @@ -105,6 +129,8 @@ internal static partial void DialAndBindFailed(
string errorMessage);

[LoggerMessage(
EventId = EventId + 12,
EventName = nameof(ListenAndBindFailed),
Message = "Listen and bind error {protocol} via {channel}: {errorMessage}",
Level = LogLevel.Error,
SkipEnabledCheck = true)]
Expand Down
4 changes: 4 additions & 0 deletions src/libp2p/Libp2p/LogMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ namespace Nethermind.Libp2p.Stack;

internal static partial class LogMessages
{
private const int EventId = 100_000;

[LoggerMessage(
EventId = EventId + 1,
EventName = nameof(LogPickedProtocol),
Message = "{protocol} has been picked to {action}",
Level = LogLevel.Debug)]
internal static partial void LogPickedProtocol(
Expand Down

0 comments on commit 4072231

Please sign in to comment.