Skip to content

Commit

Permalink
Merge 0e885d5 into 8a7ae2f
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovic committed Feb 8, 2019
2 parents 8a7ae2f + 0e885d5 commit 413abea
Show file tree
Hide file tree
Showing 37 changed files with 933 additions and 354 deletions.
7 changes: 7 additions & 0 deletions logger/logger.go
Expand Up @@ -135,6 +135,13 @@ func (s *StanLogger) Tracef(format string, v ...interface{}) {
}, format, v...)
}

// Warnf logs a warning statement
func (s *StanLogger) Warnf(format string, v ...interface{}) {
s.executeLogCall(func(logger Logger, format string, v ...interface{}) {
logger.Warnf(format, v...)
}, format, v...)
}

func (s *StanLogger) executeLogCall(f func(logger Logger, format string, v ...interface{}), format string, args ...interface{}) {
s.mu.Lock()
if s.log == nil {
Expand Down
4 changes: 4 additions & 0 deletions logger/logger_test.go
Expand Up @@ -56,6 +56,10 @@ func (d *dummyLogger) Fatalf(format string, args ...interface{}) {
d.msg = fmt.Sprintf(format, args...)
}

func (d *dummyLogger) Warnf(format string, args ...interface{}) {
d.msg = fmt.Sprintf(format, args...)
}

func (d *dummyLogger) Close() error {
return errors.New("dummy error")
}
Expand Down
2 changes: 1 addition & 1 deletion server/clustering.go
Expand Up @@ -246,7 +246,7 @@ func (rl *raftLogger) Write(b []byte) (int, error) {
case 'I': // [INFO]
rl.log.Noticef("%s", b[levelStart+7:])
case 'W': // [WARN]
rl.log.Noticef("%s", b[levelStart+7:])
rl.log.Warnf("%s", b[levelStart+7:])
case 'E': // [ERR]
rl.log.Errorf("%s", b[levelStart+6:])
default:
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Expand Up @@ -2247,7 +2247,7 @@ func (s *StanServer) recoverOneSub(c *channel, recSub *spb.SubState, pendingAcks
// Do not recover a queue durable subscriber that still
// has ClientID but for which connection was closed (=>!added)
if !added && sub.isQueueDurableSubscriber() && !sub.isShadowQueueDurable() {
s.log.Noticef("WARN: Not recovering ghost durable queue subscriber: [%s]:[%s] subject=%s inbox=%s", sub.ClientID, sub.QGroup, sub.subject, sub.Inbox)
s.log.Warnf("Not recovering ghost durable queue subscriber: [%s]:[%s] subject=%s inbox=%s", sub.ClientID, sub.QGroup, sub.subject, sub.Inbox)
c.store.Subs.DeleteSub(sub.ID)
return nil
}
Expand Down
24 changes: 18 additions & 6 deletions server/server_run_test.go
Expand Up @@ -758,6 +758,18 @@ func (l *captureNoticesLogger) Noticef(format string, args ...interface{}) {
l.Unlock()
}

type captureWarnLogger struct {
dummyLogger
warnings []string
}

func (l *captureWarnLogger) Warnf(format string, args ...interface{}) {
l.Lock()
n := fmt.Sprintf(format, args...)
l.warnings = append(l.warnings, fmt.Sprintf("%s\n", n))
l.Unlock()
}

type captureFatalLogger struct {
dummyLogger
fatal string
Expand Down Expand Up @@ -808,7 +820,7 @@ func TestGhostDurableSubs(t *testing.T) {
s.Shutdown()

// Re-open
l := &captureNoticesLogger{}
l := &captureWarnLogger{}
opts.EnableLogging = true
opts.CustomLogger = l
s = runServerWithOpts(t, opts, nil)
Expand All @@ -817,20 +829,20 @@ func TestGhostDurableSubs(t *testing.T) {
check := func(expected bool) {
present := false
l.Lock()
for _, n := range l.notices {
for _, n := range l.warnings {
if strings.Contains(n, "ghost") {
present = true
break
}
}
notices := l.notices
warnings := l.warnings
// clear the logger notices
l.notices = nil
l.warnings = nil
l.Unlock()
if expected && !present {
stackFatalf(t, "No sign of ghost warning in the log:\n%v", notices)
stackFatalf(t, "No sign of ghost warning in the log:\n%v", warnings)
} else if !expected && present {
stackFatalf(t, "The warning should no longer be in the log:\n%v", notices)
stackFatalf(t, "The warning should no longer be in the log:\n%v", warnings)
}
}
s.Shutdown()
Expand Down
1 change: 1 addition & 0 deletions server/server_test.go
Expand Up @@ -512,6 +512,7 @@ func (d *dummyLogger) Debugf(format string, args ...interface{}) { d.log(format
func (d *dummyLogger) Tracef(format string, args ...interface{}) { d.log(format, args...) }
func (d *dummyLogger) Errorf(format string, args ...interface{}) { d.log(format, args...) }
func (d *dummyLogger) Fatalf(format string, args ...interface{}) { d.log(format, args...) }
func (d *dummyLogger) Warnf(format string, args ...interface{}) { d.log(format, args...) }

func TestVersionMatchesTag(t *testing.T) {
tag := os.Getenv("TRAVIS_TAG")
Expand Down
2 changes: 1 addition & 1 deletion stores/common.go
Expand Up @@ -24,7 +24,7 @@ import (

// format string used to report that limit is reached when storing
// messages.
var droppingMsgsFmt = "WARNING: Reached limits for store %q (msgs=%v/%v bytes=%v/%v), " +
var droppingMsgsFmt = "Reached limits for store %q (msgs=%v/%v bytes=%v/%v), " +
"dropping old messages to make room for new ones"

// commonStore contains everything that is common to any type of store
Expand Down
2 changes: 1 addition & 1 deletion stores/filestore.go
Expand Up @@ -2870,7 +2870,7 @@ func (ms *FileMsgStore) enforceLimits(reportHitLimit, lockFile bool) error {
ms.removeFirstMsg(nil, lockFile)
if reportHitLimit && !ms.hitLimit {
ms.hitLimit = true
ms.log.Noticef(droppingMsgsFmt, ms.subject, ms.totalCount, ms.limits.MaxMsgs,
ms.log.Warnf(droppingMsgsFmt, ms.subject, ms.totalCount, ms.limits.MaxMsgs,
util.FriendlyBytes(int64(ms.totalBytes)), util.FriendlyBytes(ms.limits.MaxBytes))
}
}
Expand Down
2 changes: 1 addition & 1 deletion stores/memstore.go
Expand Up @@ -120,7 +120,7 @@ func (ms *MemoryMsgStore) Store(m *pb.MsgProto) (uint64, error) {
ms.removeFirstMsg()
if !ms.hitLimit {
ms.hitLimit = true
ms.log.Noticef(droppingMsgsFmt, ms.subject, ms.totalCount, ms.limits.MaxMsgs,
ms.log.Warnf(droppingMsgsFmt, ms.subject, ms.totalCount, ms.limits.MaxMsgs,
util.FriendlyBytes(int64(ms.totalBytes)), util.FriendlyBytes(ms.limits.MaxBytes))
}
}
Expand Down
2 changes: 1 addition & 1 deletion stores/sqlstore.go
Expand Up @@ -1416,7 +1416,7 @@ func (ms *SQLMsgStore) Store(m *pb.MsgProto) (uint64, error) {
}
if !ms.hitLimit {
ms.hitLimit = true
ms.log.Noticef(droppingMsgsFmt, ms.subject, ms.totalCount, ms.limits.MaxMsgs,
ms.log.Warnf(droppingMsgsFmt, ms.subject, ms.totalCount, ms.limits.MaxMsgs,
util.FriendlyBytes(int64(ms.totalBytes)), util.FriendlyBytes(ms.limits.MaxBytes))
}
}
Expand Down
1 change: 1 addition & 0 deletions stores/sqlstore_test.go
Expand Up @@ -1302,6 +1302,7 @@ func (d *getExclusiveLockLogger) log(format string, args ...interface{}) {
func (d *getExclusiveLockLogger) Noticef(format string, args ...interface{}) {}
func (d *getExclusiveLockLogger) Debugf(format string, args ...interface{}) {}
func (d *getExclusiveLockLogger) Tracef(format string, args ...interface{}) {}
func (d *getExclusiveLockLogger) Warnf(format string, args ...interface{}) {}
func (d *getExclusiveLockLogger) Errorf(format string, args ...interface{}) { d.log(format, args...) }
func (d *getExclusiveLockLogger) Fatalf(format string, args ...interface{}) { d.log(format, args...) }

Expand Down
18 changes: 9 additions & 9 deletions vendor/github.com/nats-io/gnatsd/conf/parse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions vendor/github.com/nats-io/gnatsd/logger/log.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/nats-io/gnatsd/logger/syslog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/nats-io/gnatsd/logger/syslog_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/nats-io/gnatsd/main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 24 additions & 3 deletions vendor/github.com/nats-io/gnatsd/server/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions vendor/github.com/nats-io/gnatsd/server/ciphersuites.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 413abea

Please sign in to comment.