nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: go-kit/kit
Pull request #990 (2020-06-12 06:18:10)

Add Version to JSON-RPC client request
This tiny PR addresses the issue with JSON-RPC client: https://github.com/go-kit/kit/issues/986

For some reason current implementation leaves `jsonrpc` field empty and there is no easy way to change it (there is a workaround with `ClientBefore` which is not a good option). Some server implementations require this field to be `2.0`.

According to the documentation go-kit implementation only supports v2.0, that is why I don't think this parameter should be configurable.

peterbourgon: Thanks!

Patch:
diff --git a/transport/http/jsonrpc/client.go b/transport/http/jsonrpc/client.go
index 4d8fe30..07b673d 100644
--- a/transport/http/jsonrpc/client.go
+++ b/transport/http/jsonrpc/client.go
@@ -164,7 +164,7 @@ func (c Client) Endpoint() endpoint.Endpoint {
 			return nil, err
 		}
 		rpcReq := clientRequest{
-			JSONRPC: "",
+			JSONRPC: Version,
 			Method:  c.method,
 			Params:  params,
 			ID:      c.requestID.Generate(),


Test patch:
diff --git a/transport/http/jsonrpc/client_test.go b/transport/http/jsonrpc/client_test.go
index 3b4f1ea..bbc3748 100644
--- a/transport/http/jsonrpc/client_test.go
+++ b/transport/http/jsonrpc/client_test.go
@@ -133,6 +133,9 @@ func TestClientHappyPath(t *testing.T) {
 	if id, _ := requestAtServer.ID.Int(); id != wantID {
 		t.Fatalf("Request ID at server: want=%d, got=%d", wantID, id)
 	}
+	if requestAtServer.JSONRPC != jsonrpc.Version {
+		t.Fatalf("JSON-RPC version at server: want=%s, got=%s", jsonrpc.Version, requestAtServer.JSONRPC)
+	}
 
 	var paramsAtServer addRequest
 	err = json.Unmarshal(requestAtServer.Params, &paramsAtServer)
Repository: go-kit/kit
Pull request #1041 (2020-11-29 15:51:59)

Capture newlines in log stdlib
Capture newlines in the stdlib adapter messages. Avoids cutting off
multi-line log messages.

See: https://github.com/prometheus/node_exporter/issues/1886

Signed-off-by: Ben Kochie <superq@gmail.com>

peterbourgon: Thanks!

Patch:
diff --git a/log/stdlib.go b/log/stdlib.go
index 2d030c4..0338edb 100644
--- a/log/stdlib.go
+++ b/log/stdlib.go
@@ -131,7 +131,7 @@ const (
 	logRegexpDate = `(?P<date>[0-9]{4}/[0-9]{2}/[0-9]{2})?[ ]?`
 	logRegexpTime = `(?P<time>[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?)?[ ]?`
 	logRegexpFile = `(?P<file>.+?:[0-9]+)?`
-	logRegexpMsg  = `(: )?(?P<msg>.*)`
+	logRegexpMsg  = `(: )?(?P<msg>(?s:.*))`
 )
 
 var (
@@ -145,7 +145,7 @@ func subexps(line []byte) map[string]string {
 	}
 	result := map[string]string{}
 	for i, name := range logRegexp.SubexpNames() {
-		result[name] = string(m[i])
+		result[name] = strings.TrimRight(string(m[i]), "\n")
 	}
 	return result
 }


Test patch:
diff --git a/log/stdlib_test.go b/log/stdlib_test.go
index ae9d82c..2f958b7 100644
--- a/log/stdlib_test.go
+++ b/log/stdlib_test.go
@@ -130,6 +130,12 @@ func TestStdlibAdapterSubexps(t *testing.T) {
 			"file": "",
 			"msg":  "hello world",
 		},
+		"hello\nworld": {
+			"date": "",
+			"time": "",
+			"file": "",
+			"msg":  "hello\nworld",
+		},
 		"2009/01/23: hello world": {
 			"date": "2009/01/23",
 			"time": "",
Repository: go-kratos/kratos
Pull request #715 (2021-02-22 09:20:22)

add logger wrapper
logger := log.Wrap(logrus, fluent)
logger.Print(xxx)


Patch:
diff --git a/log/log.go b/log/log.go
index 3884b6b5..8a89c7e6 100644
--- a/log/log.go
+++ b/log/log.go
@@ -1,8 +1,10 @@
 package log
 
+import "os"
+
 var (
 	// DefaultLogger is default logger.
-	DefaultLogger Logger = NewStdLogger()
+	DefaultLogger Logger = NewStdLogger(os.Stderr)
 )
 
 // Logger is a logger interface.
diff --git a/log/std.go b/log/std.go
index e5eaf6ff..6f742092 100644
--- a/log/std.go
+++ b/log/std.go
@@ -3,8 +3,8 @@ package log
 import (
 	"bytes"
 	"fmt"
+	"io"
 	"log"
-	"os"
 	"sync"
 )
 
@@ -16,9 +16,9 @@ type stdLogger struct {
 }
 
 // NewStdLogger new a std logger with options.
-func NewStdLogger() Logger {
+func NewStdLogger(w io.Writer) Logger {
 	return &stdLogger{
-		log: log.New(os.Stderr, "", log.LstdFlags),
+		log: log.New(w, "", log.LstdFlags),
 		pool: &sync.Pool{
 			New: func() interface{} {
 				return new(bytes.Buffer)
diff --git a/log/wrapper.go b/log/wrapper.go
new file mode 100644
index 00000000..0330a853
--- /dev/null
+++ b/log/wrapper.go
@@ -0,0 +1,14 @@
+package log
+
+type wrapper []Logger
+
+func (w wrapper) Print(pairs ...interface{}) {
+	for _, p := range w {
+		p.Print(pairs...)
+	}
+}
+
+// Wrap wraps multi logger.
+func Wrap(l ...Logger) Logger {
+	return wrapper(l)
+}


Test patch:
diff --git a/log/log_test.go b/log/log_test.go
index d99fc121..48cc6084 100644
--- a/log/log_test.go
+++ b/log/log_test.go
@@ -5,7 +5,7 @@ import (
 )
 
 func TestLogger(t *testing.T) {
-	logger := NewStdLogger()
+	logger := DefaultLogger
 	Debug(logger).Print("log", "test debug")
 	Info(logger).Print("log", "test info")
 	Warn(logger).Print("log", "test warn")
diff --git a/log/std_test.go b/log/std_test.go
index 60975856..2cca1394 100644
--- a/log/std_test.go
+++ b/log/std_test.go
@@ -3,7 +3,7 @@ package log
 import "testing"
 
 func TestFmtLogger(t *testing.T) {
-	logger := NewStdLogger()
+	logger := DefaultLogger
 
 	Debug(logger).Print("log", "test debug")
 	Info(logger).Print("log", "test info")
diff --git a/log/wrapper_test.go b/log/wrapper_test.go
new file mode 100644
index 00000000..e3652eb8
--- /dev/null
+++ b/log/wrapper_test.go
@@ -0,0 +1,14 @@
+package log
+
+import (
+	"os"
+	"testing"
+)
+
+func TestWrapper(t *testing.T) {
+	out := NewStdLogger(os.Stdout)
+	err := NewStdLogger(os.Stderr)
+
+	l := Wrap(out, err)
+	l.Print("message", "test")
+}