Skip to content

Move to slog for logging #722

@MattBrittan

Description

@MattBrittan

Note: This issue was raised to promote discussion of PR #718

There are a few issues with logging in this library:

  • The logger is global which can make it difficult to find messages when there are multiple connections
  • The global nature of the logger invites data races (and there are some hacks in the tests to avoid this)
  • Logging is not intuative (suspect many devs are now used to slog and the approach used here seems archaic)
  • Messages would be easier to handle/process if structured logging was used

Given that slog has been part of the standard library since Go 1.21 I think it makes sense to adopt this. I believe it should be possible to make this change in a non-breaking way (and would not move ahead if breaking changes are needed). However I don't consider changes to the logged messages themselves to be breaking (so if anyone is looking for strings within the messages then that may break).

Would really appreciate comments on this change, and the linked PR as I am not currently using this library in production (have moved everything to the V5 client).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions