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

Improve logging #41

Open
flcl42 opened this issue Sep 11, 2023 · 4 comments
Open

Improve logging #41

flcl42 opened this issue Sep 11, 2023 · 4 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@flcl42
Copy link
Contributor

flcl42 commented Sep 11, 2023

@flcl42 flcl42 added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 11, 2023
@flcl42 flcl42 added this to the beta milestone Sep 14, 2023
chertby added a commit to chertby/dotnet-libp2p that referenced this issue Sep 20, 2023
chertby added a commit to chertby/dotnet-libp2p that referenced this issue Sep 22, 2023
flcl42 pushed a commit that referenced this issue Sep 26, 2023
chertby added a commit that referenced this issue Sep 27, 2023
@chertby
Copy link
Collaborator

chertby commented Sep 29, 2023

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
    • and so forth

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 added a commit to chertby/dotnet-libp2p that referenced this issue Sep 29, 2023
@flcl42
Copy link
Contributor Author

flcl42 commented Oct 11, 2023

@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.

@chertby
Copy link
Collaborator

chertby commented Oct 11, 2023

@flcl42 I’ll prepare a simpler version today.

@chertby
Copy link
Collaborator

chertby commented Oct 12, 2023

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);

chertby added a commit to chertby/dotnet-libp2p that referenced this issue Oct 17, 2023
chertby added a commit that referenced this issue Oct 17, 2023
chertby added a commit to chertby/dotnet-libp2p that referenced this issue Oct 17, 2023
flcl42 pushed a commit that referenced this issue Oct 23, 2023
chertby added a commit that referenced this issue Nov 5, 2023
chertby added a commit that referenced this issue Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants