[
https://issues.apache.org/jira/browse/SCB-927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16626642#comment-16626642
]
ASF GitHub Bot commented on SCB-927:
------------------------------------
little-cui closed pull request #445: SCB-927 The latest Lager is not compatible
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/445
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/glide.yaml b/glide.yaml
index f18baaa3..fcea4021 100644
--- a/glide.yaml
+++ b/glide.yaml
@@ -4,7 +4,7 @@ import:
version: 91facc4ae520fef82c9aee6b6ae720d9ae789131
repo: https://github.com/Knetic/govaluate
- package: github.com/go-chassis/paas-lager
- version: master
+ version: 50655443dc96e3d633667ca6310251ba2a3fe5c9
repo: https://github.com/go-chassis/paas-lager
subpackages:
- third_party/forked/cloudfoundry/lager
@@ -356,8 +356,8 @@ import:
- pkg/version
- pkg/watch
- package: github.com/golang/glog
- version: 2cc4b790554d1a0c48fcc3aeb891e3de70cf8de0
- repo: https://github.com/istio/glog
+ version: 95a09b2413e9d5d7c26c85f0ed3cff886cba7f1e
+ repo: https://github.com/go-chassis/glog
- package: github.com/googleapis/gnostic
version: v0.1.0
repo: https://github.com/googleapis/gnostic
diff --git a/go.mod b/go.mod
index ff876244..f9ee3077 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,7 @@
module github.com/apache/incubator-servicecomb-service-center
replace (
- github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b =>
github.com/istio/glog v0.0.0-20180224222734-2cc4b790554d
+ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b =>
github.com/go-chassis/glog v0.0.0-20180920075250-95a09b2413e9
go.uber.org/zap v1.9.0 => github.com/uber-go/zap v1.9.0
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac =>
github.com/golang/crypto v0.0.0-20180820150726-614d502a4dac
golang.org/x/net v0.0.0-20180824152047-4bcd98cce591 =>
github.com/golang/net v0.0.0-20180824152047-4bcd98cce591
@@ -32,7 +32,7 @@ require (
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21
// indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
- github.com/go-chassis/paas-lager v0.0.0-20180905100939-eff93e5e67db
+ github.com/go-chassis/paas-lager v0.0.0-20180727081842-50655443dc96
github.com/go-logfmt/logfmt v0.3.0 // indirect
github.com/go-mesh/openlogging v0.0.0-20180905092207-9cc15d7752d3 //
indirect
github.com/gogo/protobuf v1.1.1 // indirect
diff --git a/pkg/log/lager.go b/pkg/log/lager.go
index 2d88a077..d13e8fa5 100644
--- a/pkg/log/lager.go
+++ b/pkg/log/lager.go
@@ -18,17 +18,12 @@
package log
import (
- "fmt"
"github.com/apache/incubator-servicecomb-service-center/pkg/util"
stlager "github.com/go-chassis/paas-lager"
"github.com/go-chassis/paas-lager/third_party/forked/cloudfoundry/lager"
- "os"
"runtime/debug"
- "time"
)
-const loggerCallerSkip = 1
-
var (
defaultLagerConfig = stlager.DefaultConfig()
stdOutWriters = []string{"stdout"}
@@ -84,7 +79,7 @@ func toLagerConfig(c Config) stlager.Config {
// newLog new log, unsafe
func NewLogger(cfg Config) *Logger {
if cfg.CallerSkip == 0 {
- cfg.CallerSkip = loggerCallerSkip
+ cfg.CallerSkip = globalCallerSkip
}
stlager.Init(toLagerConfig(cfg))
return &Logger{
@@ -99,17 +94,8 @@ type Logger struct {
}
func (l *Logger) Recover(r interface{}, callerSkip int) {
- file, method, line, ok := util.GetCaller(callerSkip +
l.Config.CallerSkip)
- if ok {
- l.Errorf(nil, "recover from %s %s():%d! %v",
util.FileLastName(file), method, line, r)
- return
- }
-
- file, method, line, _ = util.GetCaller(0)
- fmt.Fprintf(os.Stderr, "%s %s %s %d %s %s():%d %v\n",
- time.Now().Format("2006-01-02T15:04:05.000Z07:00"), "FATAL",
"system", os.Getpid(),
- util.FileLastName(file), method, line, r)
- fmt.Fprintln(os.Stderr, util.BytesToStringWithNoCopy(debug.Stack()))
+ l.Errorf(nil, "recover from panic, %v", r)
+ l.Error(util.BytesToStringWithNoCopy(debug.Stack()), nil)
}
func (l *Logger) Sync() {
diff --git a/pkg/log/log.go b/pkg/log/log.go
index aac012d4..99893d25 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -29,13 +29,13 @@ import (
const (
defaultLogLevel = "DEBUG"
- globalCallerSkip = 2
+ globalCallerSkip = 1
defaultLogRotatePeriod = 30 * time.Second
)
//log var
var (
- logger = NewLogger(Configure().WithCallerSkip(globalCallerSkip))
+ logger = NewLogger(Configure())
globalConfig Config
globalLogLevel lager.LogLevel
)
diff --git a/pkg/log/log_test.go b/pkg/log/log_test.go
index 388577dd..be79e9c8 100644
--- a/pkg/log/log_test.go
+++ b/pkg/log/log_test.go
@@ -85,8 +85,15 @@ func TestNewLogger(t *testing.T) {
}
func TestLogPanic(t *testing.T) {
+ defer func() {
+ defer func() {
+ LogPanic(recover())
+ }()
+ panic("bbb")
+ }()
defer Recover()
- panic("aaa")
+ var a *int
+ *a = 0
}
func BenchmarkLogger(b *testing.B) {
diff --git a/pkg/log/logger.go b/pkg/log/logger.go
index 1ba8fc62..f28af96e 100644
--- a/pkg/log/logger.go
+++ b/pkg/log/logger.go
@@ -97,7 +97,7 @@ func LogInfoOrWarnf(start time.Time, format string, args
...interface{}) {
// LogPanic is a function can only be called in defer function.
func LogPanic(r interface{}) {
- logger.Recover(r, 3) // LogPanic()<-defer()<-panic()<-final caller
+ logger.Recover(r, 3) // LogPanic()<-Recover()<-panic()<-final caller
}
// Recover is a function call recover() and print the stack in log
diff --git a/pkg/log/zap.go b/pkg/log/zap.go
index 3b987df3..828090f2 100644
--- a/pkg/log/zap.go
+++ b/pkg/log/zap.go
@@ -31,8 +31,7 @@ import (
)
const (
- defaultLogLevel = "DEBUG"
- loggerCallerSkip = 1
+ defaultLogLevel = "DEBUG"
)
var (
@@ -76,7 +75,7 @@ func Configure() Config {
return Config{
LoggerLevel: defaultLogLevel,
LogFormatText: true,
- CallerSkip: loggerCallerSkip,
+ CallerSkip: globalCallerSkip,
}
}
@@ -199,14 +198,11 @@ func (l *Logger) Recover(r interface{}, callerSkip int) {
e := zapcore.Entry{
Level: zap.PanicLevel, // zapcore sync automatically when
larger than ErrorLevel
Time: time.Now(),
- Caller: zapcore.NewEntryCaller(runtime.Caller(callerSkip +
l.Config.CallerSkip)),
+ Caller: zapcore.NewEntryCaller(runtime.Caller(callerSkip + 1)),
Stack: zap.Stack("stack").String,
}
if err := l.zapLogger.Core().With([]zap.Field{zap.Reflect("recover",
r)}).Write(e, nil); err != nil {
- file, _, line, _ := util.GetCaller(0)
- fmt.Fprintf(StderrSyncer, "%s\tERROR\t%s:%d\t%v\n",
- time.Now().Format("2006-01-02T15:04:05.000Z0700"),
- util.FileLastName(file), line, err)
+ fmt.Fprintf(StderrSyncer, "%s\tERROR\t%v\n",
time.Now().Format("2006-01-02T15:04:05.000Z0700"), err)
fmt.Fprintln(StderrSyncer,
util.BytesToStringWithNoCopy(debug.Stack()))
StderrSyncer.Sync()
return
diff --git a/scripts/release/LICENSE b/scripts/release/LICENSE
index ab0467bb..91e8ef18 100644
--- a/scripts/release/LICENSE
+++ b/scripts/release/LICENSE
@@ -242,7 +242,6 @@ gopkg.in/yaml.v2 (d670f9405373e636a5a2765eea47fac0c9bc91a4)
k8s.io/client-go (release-7.0)
k8s.io/api (kubernetes-1.10.4)
k8s.io/apimachinery (kubernetes-1.10.4)
-github.com/istio/glog (2cc4b790554d1a0c48fcc3aeb891e3de70cf8de0)
github.com/googleapis/gnostic (v0.1.0)
github.com/google/gofuzz (24818f796faf91cd76ec7bddd72458fbced7a6c1)
gopkg.in/inf.v0 (v0.9.1)
diff --git a/server/service/util/dependency_util.go
b/server/service/util/dependency_util.go
index 61249b47..348e0003 100644
--- a/server/service/util/dependency_util.go
+++ b/server/service/util/dependency_util.go
@@ -429,7 +429,8 @@ func DeleteDependencyForDeleteService(domainProject string,
serviceId string, se
func removeProviderRuleOfConsumer(ctx context.Context, domainProject string,
cache map[string]bool) ([]registry.PluginOp, error) {
key := apt.GenerateConsumerDependencyRuleKey(domainProject, nil) +
apt.SPLIT
- resp, err := backend.Store().DependencyRule().Search(ctx,
registry.WithStrKey(key), registry.WithPrefix())
+ resp, err := backend.Store().DependencyRule().Search(ctx,
+ registry.WithStrKey(key), registry.WithPrefix())
if err != nil {
return nil, err
}
@@ -479,7 +480,8 @@ loop:
func removeProviderRuleKeys(ctx context.Context, domainProject string, cache
map[string]bool) ([]registry.PluginOp, error) {
key := apt.GenerateProviderDependencyRuleKey(domainProject, nil) +
apt.SPLIT
- resp, err := backend.Store().DependencyRule().Search(ctx,
registry.WithStrKey(key), registry.WithPrefix())
+ resp, err := backend.Store().DependencyRule().Search(ctx,
+ registry.WithStrKey(key), registry.WithPrefix(),
registry.WithKeyOnly())
if err != nil {
return nil, err
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> The latest Lager is not compatible
> ----------------------------------
>
> Key: SCB-927
> URL: https://issues.apache.org/jira/browse/SCB-927
> Project: Apache ServiceComb
> Issue Type: Bug
> Components: Service-Center
> Reporter: little-cui
> Assignee: little-cui
> Priority: Major
> Fix For: service-center-1.1.0
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)