1
0
Fork 0
mirror of https://github.com/sourcegraph/jsonrpc2.git synced 2026-06-17 12:40:03 +02:00

Replaced log.Logger parameter by interface (#20)

This commit is contained in:
Sergey Mudrik 2018-08-31 19:05:25 +03:00 committed by Keegan Carruthers-Smith
parent 073230af28
commit 549eb959f0

View file

@ -2,10 +2,15 @@ package jsonrpc2
import (
"encoding/json"
"log"
"sync"
)
// Logger interface implements one method - Printf.
// You can use the stdlib logger *log.Logger
type Logger interface {
Printf(format string, v ...interface{})
}
// ConnOpt is the type of function that can be passed to NewConn to
// customize the Conn before it is created.
type ConnOpt func(*Conn)
@ -24,7 +29,7 @@ func OnSend(f func(*Request, *Response)) ConnOpt {
// LogMessages causes all messages sent and received on conn to be
// logged using the provided logger.
func LogMessages(log *log.Logger) ConnOpt {
func LogMessages(log Logger) ConnOpt {
return func(c *Conn) {
// Remember reqs we have received so we can helpfully show the
// request method in OnSend for responses.