Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): #41 add event ids #55

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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