-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
224 additions
and
79 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
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
10 changes: 10 additions & 0 deletions
10
src/libp2p/Libp2p.Core/Extensions/ChannelFactoryExtensions.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,10 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: MIT | ||
|
||
namespace Nethermind.Libp2p.Core.Extensions; | ||
|
||
internal static class ChannelFactoryExtensions | ||
{ | ||
public static IEnumerable<string> GetSubProtocols(this ChannelFactory? channelFactory) | ||
=> channelFactory?.SubProtocols.Select(protocol => protocol.Id) ?? Enumerable.Empty<string>(); | ||
} |
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,10 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: MIT | ||
|
||
namespace Nethermind.Libp2p.Core.Extensions; | ||
|
||
internal static class ExceptionExtensions | ||
{ | ||
public static string GetErrorMessage(this Exception? exception) | ||
=> exception?.Message ?? "unknown"; | ||
} |
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,117 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: MIT | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Nethermind.Libp2p.Core; | ||
|
||
internal static partial class LogMessages | ||
{ | ||
[LoggerMessage( | ||
Message = "Read chunk {bytes} bytes", | ||
Level = LogLevel.Trace)] | ||
internal static partial void ReadChunk( | ||
this ILogger logger, | ||
long bytes); | ||
|
||
[LoggerMessage( | ||
Message = "Read enough {bytes} bytes", | ||
Level = LogLevel.Trace)] | ||
internal static partial void ReadEnough( | ||
this ILogger logger, | ||
long bytes); | ||
|
||
[LoggerMessage( | ||
Message = "Write {bytes} bytes", | ||
Level = LogLevel.Trace)] | ||
internal static partial void WriteBytes( | ||
this ILogger logger, | ||
long bytes); | ||
|
||
[LoggerMessage( | ||
Message = "Dial {channel} on protocol {protocol} with sub-protocols {subProtocols}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void DialStarted( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
IEnumerable<string> subProtocols); | ||
|
||
[LoggerMessage( | ||
Message = "Listen {channel} on protocol {protocol} with sub-protocols {subProtocols}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void ListenStarted( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
IEnumerable<string> subProtocols); | ||
|
||
[LoggerMessage( | ||
Message = "Dial and bind {channel} on protocol {protocol} with sub-protocols {subProtocols}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void DialAndBindStarted( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
IEnumerable<string> subProtocols); | ||
|
||
[LoggerMessage( | ||
Message = "Listen and bind {channel} on protocol {protocol} with sub-protocols {subProtocols}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void ListenAndBindStarted( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
IEnumerable<string> subProtocols); | ||
|
||
[LoggerMessage( | ||
Message = "Create channel {chan}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void ChannelCreated( | ||
this ILogger logger, | ||
string chan); | ||
|
||
[LoggerMessage( | ||
Message = "Dial error {protocol} via {channel}: {errorMessage}", | ||
Level = LogLevel.Error, | ||
SkipEnabledCheck = true)] | ||
internal static partial void DialFailed( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
Exception? exception, | ||
string errorMessage); | ||
|
||
[LoggerMessage( | ||
Message = "Listen error {protocol} via {channel}: {errorMessage}", | ||
Level = LogLevel.Error, | ||
SkipEnabledCheck = true)] | ||
internal static partial void ListenFailed( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
Exception? exception, | ||
string errorMessage); | ||
|
||
[LoggerMessage( | ||
Message = "Dial and bind error {protocol} via {channel}: {errorMessage}", | ||
Level = LogLevel.Error, | ||
SkipEnabledCheck = true)] | ||
internal static partial void DialAndBindFailed( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
Exception? exception, | ||
string errorMessage); | ||
|
||
[LoggerMessage( | ||
Message = "Listen and bind error {protocol} via {channel}: {errorMessage}", | ||
Level = LogLevel.Error, | ||
SkipEnabledCheck = true)] | ||
internal static partial void ListenAndBindFailed( | ||
this ILogger logger, | ||
string channel, | ||
string protocol, | ||
Exception? exception, | ||
string errorMessage); | ||
} |