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(core): NethermindEth#41 improve logging
- Loading branch information
Showing
3 changed files
with
83 additions
and
20 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
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,59 @@ | ||
// 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 = "{method} {chan} on protocol {protocols} with sub-protocols {subProtocols}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void LogAction( | ||
this ILogger logger, | ||
string method, | ||
string chan, | ||
string protocol, | ||
IEnumerable<string> subProtocols); | ||
|
||
[LoggerMessage( | ||
Message = "Create chan {chan}", | ||
Level = LogLevel.Debug)] | ||
internal static partial void ChanCreated( | ||
this ILogger logger, | ||
string chan); | ||
|
||
[LoggerMessage( | ||
Message = "{method} error {protocol} via {chan}: {errorMessage}", | ||
Level = LogLevel.Error, | ||
SkipEnabledCheck = true)] | ||
internal static partial void LogCompletedUnsuccessfully( | ||
this ILogger logger, | ||
string method, | ||
string chan, | ||
string protocol, | ||
Exception? exception, | ||
string errorMessage); | ||
} |