From 2ee959a05b0a9e7e67e16a8ecd98e10d33b0effd Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 26 Aug 2017 15:03:40 -0400 Subject: [PATCH] nsqd: diskqueue now takes AppLogFunc instead of Logger diskqueue support for log levels --- Godeps | 2 +- nsqd/channel.go | 11 +++++++++-- nsqd/topic.go | 11 +++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Godeps b/Godeps index cfcf8ca0b..3dd9deba2 100644 --- a/Godeps +++ b/Godeps @@ -8,4 +8,4 @@ github.com/bitly/timer_metrics afad1794bb13e2a094720aeb27c088aa64564895 github.com/blang/semver 9bf7bff48b0388cb75991e58c6df7d13e982f1f2 github.com/julienschmidt/httprouter 6aacfd5ab513e34f7e64ea9627ab9670371b34e7 github.com/judwhite/go-svc/svc 63c12402f579f0bdf022653c821a1aa5d7544f01 -github.com/nsqio/go-diskqueue d7805f889b023afcd5b8933e815ce9ba36327333 +github.com/nsqio/go-diskqueue 0681a1afee1245efa503b7543989fc26d8f268bc diff --git a/nsqd/channel.go b/nsqd/channel.go index aa1cba27b..99ee6ac8d 100644 --- a/nsqd/channel.go +++ b/nsqd/channel.go @@ -11,6 +11,7 @@ import ( "time" "github.com/nsqio/go-diskqueue" + "github.com/nsqio/nsq/internal/lg" "github.com/nsqio/nsq/internal/pqueue" "github.com/nsqio/nsq/internal/quantile" ) @@ -94,16 +95,22 @@ func NewChannel(topicName string, channelName string, ctx *context, c.ephemeral = true c.backend = newDummyBackendQueue() } else { + dqLogf := func(level diskqueue.LogLevel, f string, args ...interface{}) { + opts := ctx.nsqd.getOpts() + lg.Logf(opts.Logger, opts.logLevel, lg.LogLevel(level), f, args...) + } // backend names, for uniqueness, automatically include the topic... backendName := getBackendName(topicName, channelName) - c.backend = diskqueue.New(backendName, + c.backend = diskqueue.New( + backendName, ctx.nsqd.getOpts().DataPath, ctx.nsqd.getOpts().MaxBytesPerFile, int32(minValidMsgLength), int32(ctx.nsqd.getOpts().MaxMsgSize)+minValidMsgLength, ctx.nsqd.getOpts().SyncEvery, ctx.nsqd.getOpts().SyncTimeout, - ctx.nsqd.getOpts().Logger) + dqLogf, + ) } c.ctx.nsqd.Notify(c) diff --git a/nsqd/topic.go b/nsqd/topic.go index 7cd4cd9f9..fcf64b1ae 100644 --- a/nsqd/topic.go +++ b/nsqd/topic.go @@ -9,6 +9,7 @@ import ( "time" "github.com/nsqio/go-diskqueue" + "github.com/nsqio/nsq/internal/lg" "github.com/nsqio/nsq/internal/quantile" "github.com/nsqio/nsq/internal/util" ) @@ -57,14 +58,20 @@ func NewTopic(topicName string, ctx *context, deleteCallback func(*Topic)) *Topi t.ephemeral = true t.backend = newDummyBackendQueue() } else { - t.backend = diskqueue.New(topicName, + dqLogf := func(level diskqueue.LogLevel, f string, args ...interface{}) { + opts := ctx.nsqd.getOpts() + lg.Logf(opts.Logger, opts.logLevel, lg.LogLevel(level), f, args...) + } + t.backend = diskqueue.New( + topicName, ctx.nsqd.getOpts().DataPath, ctx.nsqd.getOpts().MaxBytesPerFile, int32(minValidMsgLength), int32(ctx.nsqd.getOpts().MaxMsgSize)+minValidMsgLength, ctx.nsqd.getOpts().SyncEvery, ctx.nsqd.getOpts().SyncTimeout, - ctx.nsqd.getOpts().Logger) + dqLogf, + ) } t.waitGroup.Wrap(func() { t.messagePump() })