mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 12:54:01 +03:00
Intergrate custom logger where applicable
This commit is contained in:
+4
-6
@@ -6,14 +6,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/9seconds/mtg/v2/events"
|
||||
"github.com/9seconds/mtg/v2/logger"
|
||||
"github.com/9seconds/mtg/v2/mtglib"
|
||||
statsd "github.com/smira/go-statsd"
|
||||
)
|
||||
|
||||
type statsdFakeLogger struct{}
|
||||
|
||||
func (s statsdFakeLogger) Printf(msg string, args ...interface{}) {}
|
||||
|
||||
type statsdProcessor struct {
|
||||
streams map[string]*streamInfo
|
||||
client *statsd.Client
|
||||
@@ -92,10 +89,11 @@ func (s StatsdFactory) Make() events.Observer {
|
||||
}
|
||||
}
|
||||
|
||||
func NewStatsd(address, metricPrefix, tagFormat string) (StatsdFactory, error) {
|
||||
func NewStatsd(address string, log logger.StdLikeLogger,
|
||||
metricPrefix, tagFormat string) (StatsdFactory, error) {
|
||||
options := []statsd.Option{
|
||||
statsd.MetricPrefix(metricPrefix),
|
||||
statsd.Logger(statsdFakeLogger{}),
|
||||
statsd.Logger(log),
|
||||
}
|
||||
|
||||
switch strings.ToLower(tagFormat) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/9seconds/mtg/v2/events"
|
||||
"github.com/9seconds/mtg/v2/logger"
|
||||
"github.com/9seconds/mtg/v2/mtglib"
|
||||
"github.com/9seconds/mtg/v2/stats"
|
||||
statsd "github.com/smira/go-statsd"
|
||||
@@ -80,7 +81,8 @@ type StatsdTestSuite struct {
|
||||
func (suite *StatsdTestSuite) SetupTest() {
|
||||
suite.statsdServer = statsdNewFakeServer()
|
||||
|
||||
factory, err := stats.NewStatsd(suite.statsdServer.Addr(), "mtg.", "datadog")
|
||||
factory, err := stats.NewStatsd(suite.statsdServer.Addr(),
|
||||
logger.NewNoopLogger(), "mtg.", "datadog")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user