Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

switch to logrus logging library #1056

Merged
merged 4 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Gopkg.lock

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

8 changes: 2 additions & 6 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ unused-packages = true
version = "1.10.1"

[[constraint]]
name = "github.com/Sirupsen/logrus"
version = "0.7.3"
name = "github.com/sirupsen/logrus"
version = "1.0.6"

[[constraint]]
name = "github.com/alyu/configparser"
Expand Down Expand Up @@ -128,10 +128,6 @@ unused-packages = true
name = "github.com/raintank/schema"
branch = "deprecate-gopkg-in"

[[constraint]]
name = "github.com/raintank/worldping-api"
revision = "66b28f1160d1e0d7d236b5bd96a5d8eee627357c"

[[constraint]]
name = "github.com/rakyll/globalconf"
branch = "master"
Expand Down
12 changes: 5 additions & 7 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import (
"github.com/grafana/metrictank/mdata/cache"
"github.com/grafana/metrictank/stats"
opentracing "github.com/opentracing/opentracing-go"
"github.com/raintank/worldping-api/pkg/log"
log "github.com/sirupsen/logrus"
"gopkg.in/macaron.v1"
)

var LogLevel int

var (
// metric api.get_target is how long it takes to get a target
getTargetDuration = stats.NewLatencyHistogram15s32("api.get_target")
Expand Down Expand Up @@ -113,12 +111,12 @@ func (s *Server) Run() {
if s.SSL {
proto = "https"
}
log.Info("API Listening on: %v://%s/", proto, s.Addr)
log.Infof("API Listening on: %v://%s/", proto, s.Addr)

// define our own listner so we can call Close on it
l, err := net.Listen("tcp", s.Addr)
if err != nil {
log.Fatal(4, "API failed to listen on %s, %s", s.Addr, err.Error())
log.Fatalf("API failed to listen on %s, %s", s.Addr, err.Error())
}
go s.handleShutdown(l)
srv := http.Server{
Expand All @@ -129,7 +127,7 @@ func (s *Server) Run() {
var cert tls.Certificate
cert, err = tls.LoadX509KeyPair(s.certFile, s.keyFile)
if err != nil {
log.Fatal(4, "API Failed to start server: %v", err)
log.Fatalf("API Failed to start server: %v", err)
}
srv.TLSConfig = &tls.Config{
Certificates: []tls.Certificate{cert},
Expand All @@ -142,7 +140,7 @@ func (s *Server) Run() {
}

if err != nil {
log.Info("API %s", err.Error())
log.Infof("API %s", err.Error())
}
}

Expand Down
8 changes: 4 additions & 4 deletions api/ccache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/grafana/metrictank/api/response"
"github.com/grafana/metrictank/cluster"
"github.com/grafana/metrictank/idx"
"github.com/raintank/worldping-api/pkg/log"
log "github.com/sirupsen/logrus"
)

func (s *Server) ccacheDelete(ctx *middleware.Context, req models.CCacheDelete) {
Expand Down Expand Up @@ -109,18 +109,18 @@ func (s *Server) ccacheDeletePropagate(ctx context.Context, req *models.CCacheDe
func (s *Server) ccacheDeleteRemote(ctx context.Context, req *models.CCacheDelete, peer cluster.Node) models.CCacheDeleteResp {
var res models.CCacheDeleteResp

log.Debug("HTTP metricDelete calling %s/ccache/delete", peer.GetName())
log.Debugf("HTTP metricDelete calling %s/ccache/delete", peer.GetName())
buf, err := peer.Post(ctx, "ccacheDeleteRemote", "/ccache/delete", *req)
if err != nil {
log.Error(4, "HTTP ccacheDelete error querying %s/ccache/delete: %q", peer.GetName(), err)
log.Errorf("HTTP ccacheDelete error querying %s/ccache/delete: %q", peer.GetName(), err.Error())
res.FirstError = err.Error()
res.Errors++
return res
}

err = json.Unmarshal(buf, &res)
if err != nil {
log.Error(4, "HTTP ccacheDelete error unmarshaling body from %s/ccache/delete: %q", peer.GetName(), err)
log.Errorf("HTTP ccacheDelete error unmarshaling body from %s/ccache/delete: %q", peer.GetName(), err.Error())
res.FirstError = err.Error()
res.Errors++
}
Expand Down
20 changes: 10 additions & 10 deletions api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/grafana/metrictank/api/response"
"github.com/grafana/metrictank/cluster"
"github.com/grafana/metrictank/stats"
"github.com/raintank/worldping-api/pkg/log"
log "github.com/sirupsen/logrus"
"github.com/tinylib/msgp/msgp"
)

Expand Down Expand Up @@ -210,7 +210,7 @@ func (s *Server) getData(ctx *middleware.Context, request models.GetData) {
if err != nil {
// the only errors returned are from us catching panics, so we should treat them
// all as internalServerErrors
log.Error(3, "HTTP getData() %s", err.Error())
log.Errorf("HTTP getData() %s", err.Error())
response.Write(ctx, response.WrapError(err))
return
}
Expand Down Expand Up @@ -252,11 +252,11 @@ func (s *Server) peerQuery(ctx context.Context, data cluster.Traceable, name, pa
} else {
peers, err = cluster.MembersForQuery()
if err != nil {
log.Error(3, "HTTP peerQuery unable to get peers, %s", err)
log.Errorf("HTTP peerQuery unable to get peers, %s", err.Error())
return nil, err
}
}
log.Debug("HTTP %s across %d instances", name, len(peers)-1)
log.Debugf("HTTP %s across %d instances", name, len(peers)-1)

reqCtx, cancel := context.WithCancel(ctx)
defer cancel()
Expand All @@ -273,11 +273,11 @@ func (s *Server) peerQuery(ctx context.Context, data cluster.Traceable, name, pa
wg.Add(1)
go func(peer cluster.Node) {
defer wg.Done()
log.Debug("HTTP Render querying %s%s", peer.GetName(), path)
log.Debugf("HTTP Render querying %s%s", peer.GetName(), path)
buf, err := peer.Post(reqCtx, name, path, data)
if err != nil {
cancel()
log.Error(4, "HTTP Render error querying %s%s: %q", peer.GetName(), path, err)
log.Errorf("HTTP Render error querying %s%s: %q", peer.GetName(), path, err.Error())
}
responses <- struct {
data PeerResponse
Expand Down Expand Up @@ -314,10 +314,10 @@ func (s *Server) peerQuery(ctx context.Context, data cluster.Traceable, name, pa
func (s *Server) peerQuerySpeculative(ctx context.Context, data cluster.Traceable, name, path string) (map[string]PeerResponse, error) {
peerGroups, err := cluster.MembersForSpeculativeQuery()
if err != nil {
log.Error(3, "HTTP peerQuery unable to get peers, %s", err)
log.Errorf("HTTP peerQuery unable to get peers, %s", err.Error())
return nil, err
}
log.Debug("HTTP %s across %d instances", name, len(peerGroups)-1)
log.Debugf("HTTP %s across %d instances", name, len(peerGroups)-1)

reqCtx, cancel := context.WithCancel(ctx)
defer cancel()
Expand All @@ -332,7 +332,7 @@ func (s *Server) peerQuerySpeculative(ctx context.Context, data cluster.Traceabl
}, 1)

askPeer := func(shardGroup int32, peer cluster.Node) {
log.Debug("HTTP Render querying %s%s", peer.GetName(), path)
log.Debugf("HTTP Render querying %s%s", peer.GetName(), path)
buf, err := peer.Post(reqCtx, name, path, data)

select {
Expand All @@ -344,7 +344,7 @@ func (s *Server) peerQuerySpeculative(ctx context.Context, data cluster.Traceabl

if err != nil {
cancel()
log.Error(4, "HTTP Render error querying %s%s: %q", peer.GetName(), path, err)
log.Errorf("HTTP Render error querying %s%s: %q", peer.GetName(), path, err.Error())
}
responses <- struct {
shardGroup int32
Expand Down
8 changes: 4 additions & 4 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"time"

"github.com/raintank/dur"
"github.com/raintank/worldping-api/pkg/log"
"github.com/rakyll/globalconf"
log "github.com/sirupsen/logrus"
)

var (
Expand Down Expand Up @@ -61,12 +61,12 @@ func ConfigProcess() {
//validate the addr
_, err := net.ResolveTCPAddr("tcp", Addr)
if err != nil {
log.Fatal(4, "API listen address is not a valid TCP address.")
log.Fatal("API listen address is not a valid TCP address.")
}

u, err := url.Parse(fallbackGraphite)
if err != nil {
log.Fatal(4, "API Cannot parse fallback-graphite-addr: %s", err)
log.Fatalf("API Cannot parse fallback-graphite-addr: %s", err.Error())
}
graphiteProxy = NewGraphiteProxy(u)

Expand All @@ -75,7 +75,7 @@ func ConfigProcess() {
} else {
timeZone, err = time.LoadLocation(timeZoneStr)
if err != nil {
log.Fatal(4, "API Cannot load timezone %q: %s", timeZoneStr, err)
log.Fatalf("API Cannot load timezone %q: %s", timeZoneStr, err.Error())
}
}
}
Loading