Open flcl42 opened 1 year ago
I would like to propose the implementation of an EventId
system for our logs, which will consist of six digits.
The first three digits will be related to a specific project:
1XX
: Core projects such as Libp2p
, Libp2p.Core
2XX
: Protocols, for example:
200
: Ping
201
: Plaintext
The last three digits will determine the log level and the log's ID:
000..099
: Trace
100..199
: Debug
200..299
: Information
300..399
: Warning
400..499
: Error
500..599
: Critical
For example, the complete EventId
for the Ping
protocol could be 200100
.
This system will provide a clear and structured way to identify events in our logs, making it easier to track and troubleshoot issues.
Please feel free to share your thoughts and feedback on this proposal.
I will prepare a PR for the Ping protocol to make it more clear. @flcl42
@chertby it's good to have some structure but it seems like complication for potential contributors, another rule to keep in mind. Let's start by having just incremental numbers for the messages which is already a lot.
@flcl42 I’ll prepare a simpler version today.
I still suggest leaving different event IDs for different protocols. But then use a simple increment. Use the name of the function itself as an event hire.
It’s simpler than the previous option, but we keep good logging, which should help with debugging.
I updated PR
private const int EventId = 200_000;
[LoggerMessage(
EventId = EventId + 1,
EventName = nameof(ReadingPong),
Message = "Reading pong",
Level = LogLevel.Trace)]
internal static partial void ReadingPong(
this ILogger logger);
[LoggerMessage(
EventId = EventId + 2,
EventName = nameof(VerifyingPong),
Message = "Verifying pong",
Level = LogLevel.Trace)]
internal static partial void VerifyingPong(
this ILogger logger);