From f4e9141638c411cf10c2c9c29efbb9661e45f89c Mon Sep 17 00:00:00 2001 From: lane-c-wagner Date: Wed, 7 Apr 2021 13:55:11 -0600 Subject: [PATCH] naming updates --- consume.go | 6 +++--- examples/logger/main.go | 8 ++++---- logger.go | 12 ++++++------ publish.go | 4 ++-- vendor/github.com/streadway/amqp/doc.go | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/consume.go b/consume.go index 8f5c637..2013509 100644 --- a/consume.go +++ b/consume.go @@ -34,7 +34,7 @@ func NewConsumer(url string, optionFuncs ...func(*ConsumerOptions)) (Consumer, e optionFunc(options) } if options.Logger == nil { - options.Logger = &nolog{} // default no logging + options.Logger = &noLogger{} // default no logging } chManager, err := newChannelManager(url, options.Logger) @@ -48,10 +48,10 @@ func NewConsumer(url string, optionFuncs ...func(*ConsumerOptions)) (Consumer, e return consumer, nil } -// WithConsumerOptionsLogging sets logging to true on the consumer options +// WithConsumerOptionsLogging sets a logger to log to stdout func WithConsumerOptionsLogging(options *ConsumerOptions) { options.Logging = true - options.Logger = &stdlog{} + options.Logger = &stdLogger{} } // WithConsumerOptionsLogger sets logging to a custom interface. diff --git a/examples/logger/main.go b/examples/logger/main.go index e2cab77..14d3855 100644 --- a/examples/logger/main.go +++ b/examples/logger/main.go @@ -6,16 +6,16 @@ import ( rabbitmq "github.com/wagslane/go-rabbitmq" ) -// CustomLog is used in WithPublisherOptionsLogger to create a custom logger. -type CustomLog struct{} +// customLogger is used in WithPublisherOptionsLogger to create a custom logger. +type customLogger struct{} // Printf is the only method needed in the Logger interface to function properly. -func (c *CustomLog) Printf(fmt string, args ...interface{}) { +func (c *customLogger) Printf(fmt string, args ...interface{}) { log.Printf("mylogger: "+fmt, args...) } func main() { - mylogger := &CustomLog{} + mylogger := &customLogger{} publisher, returns, err := rabbitmq.NewPublisher( "amqp://guest:guest@localhost", diff --git a/logger.go b/logger.go index 621a0ad..ebefc1f 100644 --- a/logger.go +++ b/logger.go @@ -13,14 +13,14 @@ type Logger interface { const loggingPrefix = "gorabbit" -// stdlog logs to stdout using go's default logger. -type stdlog struct{} +// stdLogger logs to stdout using go's default logger. +type stdLogger struct{} -func (l stdlog) Printf(format string, v ...interface{}) { +func (l stdLogger) Printf(format string, v ...interface{}) { log.Printf(fmt.Sprintf("%s: %s", loggingPrefix, format), v...) } -// nolog does not log at all, this is the default. -type nolog struct{} +// noLogger does not log at all, this is the default. +type noLogger struct{} -func (l nolog) Printf(format string, v ...interface{}) {} +func (l noLogger) Printf(format string, v ...interface{}) {} diff --git a/publish.go b/publish.go index 54c1e4c..1733b6c 100644 --- a/publish.go +++ b/publish.go @@ -98,7 +98,7 @@ type PublisherOptions struct { // WithPublisherOptionsLogging sets logging to true on the consumer options func WithPublisherOptionsLogging(options *PublisherOptions) { options.Logging = true - options.Logger = &stdlog{} + options.Logger = &stdLogger{} } // WithPublisherOptionsLogger sets logging to a custom interface. @@ -121,7 +121,7 @@ func NewPublisher(url string, optionFuncs ...func(*PublisherOptions)) (Publisher optionFunc(options) } if options.Logger == nil { - options.Logger = &nolog{} // default no logging + options.Logger = &noLogger{} // default no logging } chManager, err := newChannelManager(url, options.Logger) diff --git a/vendor/github.com/streadway/amqp/doc.go b/vendor/github.com/streadway/amqp/doc.go index ee69c5b..d544e0a 100644 --- a/vendor/github.com/streadway/amqp/doc.go +++ b/vendor/github.com/streadway/amqp/doc.go @@ -7,7 +7,7 @@ Package amqp is an AMQP 0.9.1 client with RabbitMQ extensions Understand the AMQP 0.9.1 messaging model by reviewing these links first. Much -of the terminology in this library directly relates to AMQP concepts. +of the terminoLoggery in this library directly relates to AMQP concepts. Resources