1
0
Fork 0
mirror of https://github.com/sourcegraph/jsonrpc2.git synced 2026-06-18 13:10:02 +02:00

use custom logger for internal logging

Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
This commit is contained in:
s3rj1k 2019-11-03 22:30:34 +02:00
parent 8819199291
commit 6053545ad1
3 changed files with 20 additions and 16 deletions

View file

@ -2,7 +2,6 @@ package jsonrpc2
import (
"context"
"log"
)
// HandlerWithError implements Handler by calling the func for each
@ -11,7 +10,6 @@ func HandlerWithError(handleFunc func(context.Context, *Conn, *Request) (result
return &HandlerWithErrorConfigurer{handleFunc: handleFunc}
}
// HandlerWithErrorConfigurer is a handler created by HandlerWithError.
type HandlerWithErrorConfigurer struct {
handleFunc func(context.Context, *Conn, *Request) (result interface{}, err error)
@ -23,7 +21,7 @@ func (h *HandlerWithErrorConfigurer) Handle(ctx context.Context, conn *Conn, req
result, err := h.handleFunc(ctx, conn, req)
if req.Notif {
if err != nil {
log.Printf("jsonrpc2 handler: notification %q handling error: %s", req.Method, err)
conn.logger.Printf("jsonrpc2 handler: notification %q handling error: %s\n", req.Method, err)
}
return
}
@ -43,7 +41,7 @@ func (h *HandlerWithErrorConfigurer) Handle(ctx context.Context, conn *Conn, req
if !req.Notif {
if err := conn.SendResponse(ctx, resp); err != nil {
if err != ErrClosed || !h.suppressErrClosed {
log.Printf("jsonrpc2 handler: sending response %s: %s", resp.ID, err)
conn.logger.Printf("jsonrpc2 handler: sending response %s: %s\n", resp.ID, err)
}
}
}