sourcegraph / jsonrpc2

Package jsonrpc2 provides a client and server implementation of JSON-RPC 2.0 (http://www.jsonrpc.org/specification)
MIT License
195 stars 62 forks source link

Add ability to set custom logger #48

Closed samherrmann closed 2 years ago

samherrmann commented 3 years ago

Before this commit, a custom logger could be set with the LogMessages function. However, by using LogMessages not only is a custom logger set but also all received and sent messages are logged. Use cases exist where a custom logger is desired to log errors but not all messages.

samherrmann commented 3 years ago

If this pull request is accepted, maybe a change to the LogMessages function should be considered so that logging all messages no longer requires a custom logger to be set (single responsibility)?

From:

func LogMessages(logger Logger) ConnOpt

To:

func LogMessages() ConnOpt

https://github.com/sourcegraph/jsonrpc2/blob/v0.1.0/conn_opt.go#L32

This would be a breaking change however.