This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-go-plugin-runner.git
The following commit(s) were added to refs/heads/master by this push:
new 1e5e53c refactor: move internal/log to pkg/log (#14)
1e5e53c is described below
commit 1e5e53ca5095b91c6a9609321ceedbc9868bfecb
Author: 罗泽轩 <[email protected]>
AuthorDate: Mon Jun 28 10:22:51 2021 +0800
refactor: move internal/log to pkg/log (#14)
---
cmd/go-runner/main.go | 10 +++++-----
cmd/go-runner/plugins/say.go | 4 ++--
internal/plugin/conf.go | 5 +++--
internal/plugin/plugin.go | 2 +-
internal/server/server.go | 2 +-
{internal => pkg}/log/log.go | 0
pkg/runner/runner.go | 2 +-
7 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/cmd/go-runner/main.go b/cmd/go-runner/main.go
index 98a0e56..109e219 100644
--- a/cmd/go-runner/main.go
+++ b/cmd/go-runner/main.go
@@ -17,7 +17,6 @@ package main
import (
"fmt"
"io"
- "log"
"os"
"path/filepath"
"runtime"
@@ -27,6 +26,7 @@ import (
"github.com/thediveo/enumflag"
"go.uber.org/zap/zapcore"
+ "github.com/apache/apisix-go-plugin-runner/pkg/log"
"github.com/apache/apisix-go-plugin-runner/pkg/runner"
)
@@ -105,11 +105,11 @@ func newRunCommand() *cobra.Command {
cpuProfileFile := ProfileFilePath + "cpu"
f, err := os.Create(cpuProfileFile)
if err != nil {
- log.Fatal("could not create CPU
profile: ", err)
+ log.Fatalf("could not create CPU
profile: %s", err)
}
defer f.Close()
if err := pprof.StartCPUProfile(f); err != nil {
- log.Fatal("could not start CPU profile:
", err)
+ log.Fatalf("could not start CPU
profile: %s", err)
}
defer pprof.StopCPUProfile()
@@ -117,13 +117,13 @@ func newRunCommand() *cobra.Command {
memProfileFile := ProfileFilePath +
"mem"
f, err := os.Create(memProfileFile)
if err != nil {
- log.Fatal("could not create
memory profile: ", err)
+ log.Fatalf("could not create
memory profile: %s", err)
}
defer f.Close()
runtime.GC()
if err := pprof.WriteHeapProfile(f);
err != nil {
- log.Fatal("could not write
memory profile: ", err)
+ log.Fatalf("could not write
memory profile: %s", err)
}
}()
}
diff --git a/cmd/go-runner/plugins/say.go b/cmd/go-runner/plugins/say.go
index bc8c558..fac4dd3 100644
--- a/cmd/go-runner/plugins/say.go
+++ b/cmd/go-runner/plugins/say.go
@@ -16,10 +16,10 @@ package plugins
import (
"encoding/json"
- "log"
"net/http"
pkgHTTP "github.com/apache/apisix-go-plugin-runner/pkg/http"
+ "github.com/apache/apisix-go-plugin-runner/pkg/log"
"github.com/apache/apisix-go-plugin-runner/pkg/plugin"
)
@@ -58,6 +58,6 @@ func (p *Say) Filter(conf interface{}, w http.ResponseWriter,
r pkgHTTP.Request)
w.Header().Add("X-Resp-A6-Runner", "Go")
_, err := w.Write([]byte(body))
if err != nil {
- log.Printf("failed to write: %s", err)
+ log.Errorf("failed to write: %s", err)
}
}
diff --git a/internal/plugin/conf.go b/internal/plugin/conf.go
index 20485fe..28103b5 100644
--- a/internal/plugin/conf.go
+++ b/internal/plugin/conf.go
@@ -20,11 +20,12 @@ import (
"time"
"github.com/ReneKroon/ttlcache/v2"
- "github.com/apache/apisix-go-plugin-runner/internal/log"
- "github.com/apache/apisix-go-plugin-runner/internal/util"
A6 "github.com/api7/ext-plugin-proto/go/A6"
pc "github.com/api7/ext-plugin-proto/go/A6/PrepareConf"
flatbuffers "github.com/google/flatbuffers/go"
+
+ "github.com/apache/apisix-go-plugin-runner/internal/util"
+ "github.com/apache/apisix-go-plugin-runner/pkg/log"
)
type ConfEntry struct {
diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go
index a33c61a..9b88ca9 100644
--- a/internal/plugin/plugin.go
+++ b/internal/plugin/plugin.go
@@ -24,9 +24,9 @@ import (
flatbuffers "github.com/google/flatbuffers/go"
inHTTP "github.com/apache/apisix-go-plugin-runner/internal/http"
- "github.com/apache/apisix-go-plugin-runner/internal/log"
"github.com/apache/apisix-go-plugin-runner/internal/util"
pkgHTTP "github.com/apache/apisix-go-plugin-runner/pkg/http"
+ "github.com/apache/apisix-go-plugin-runner/pkg/log"
)
type ParseConfFunc func(in []byte) (conf interface{}, err error)
diff --git a/internal/server/server.go b/internal/server/server.go
index e25083e..6e3ca58 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -28,9 +28,9 @@ import (
flatbuffers "github.com/google/flatbuffers/go"
- "github.com/apache/apisix-go-plugin-runner/internal/log"
"github.com/apache/apisix-go-plugin-runner/internal/plugin"
"github.com/apache/apisix-go-plugin-runner/internal/util"
+ "github.com/apache/apisix-go-plugin-runner/pkg/log"
)
const (
diff --git a/internal/log/log.go b/pkg/log/log.go
similarity index 100%
rename from internal/log/log.go
rename to pkg/log/log.go
diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go
index 6ecb4b2..0405097 100644
--- a/pkg/runner/runner.go
+++ b/pkg/runner/runner.go
@@ -19,8 +19,8 @@ import (
"go.uber.org/zap/zapcore"
- "github.com/apache/apisix-go-plugin-runner/internal/log"
"github.com/apache/apisix-go-plugin-runner/internal/server"
+ "github.com/apache/apisix-go-plugin-runner/pkg/log"
)
// RunnerConfig is the configuration of the runner