1
0
Fork 0
mirror of https://github.com/sourcegraph/jsonrpc2.git synced 2026-08-24 14:08:12 +02:00

Add ability to set custom logger (#48)

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.
This commit is contained in:
Sam Herrmann 2021-11-19 03:30:03 -05:00 committed by GitHub
parent 5f298fe6a1
commit c9c77b6bb9
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 0 deletions

View file

@ -102,3 +102,10 @@ func LogMessages(logger Logger) ConnOpt {
})(c)
}
}
// SetLogger sets the logger for the connection.
func SetLogger(logger Logger) ConnOpt {
return func(c *Conn) {
c.logger = logger
}
}