Commit c91bfd82 by Joan López de la Franca Beltran Committed by GitHub

Core: Add loki/logproto dependency (#27124)

* Add grafana/loki dependency and update its dependencies

* Update grpcplugin log_wrapper to implement the latest version of hclog.Logger

* Remove panic handling + test case no longer needed since the source of panics (bug) was fixed
parent 6a01bab6
......@@ -6,16 +6,19 @@ go 1.14
// We need a more current go-mssqldb so we get rid of a version of apache/thrift with vulnerabilities.
replace github.com/denisenkom/go-mssqldb => github.com/denisenkom/go-mssqldb v0.0.0-20200620013148-b91950f658ec
// Override k8s.io/client-go outdated dependency, which is an indirect dependency of grafana/loki.
// It's also present on grafana/loki's go.mod so we'll need till it gets updated.
replace k8s.io/client-go => k8s.io/client-go v0.18.8
require (
cloud.google.com/go v0.60.0 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/VividCortex/mysqlerr v0.0.0-20170204212430-6c6b55f8796f
github.com/aws/aws-sdk-go v1.29.20
github.com/aws/aws-sdk-go v1.33.12
github.com/beevik/etree v1.1.0 // indirect
github.com/benbjohnson/clock v0.0.0-20161215174838-7dc76406b6d3
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
github.com/centrifugal/centrifuge v0.10.0
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/crewjam/saml v0.0.0-20191031171751-c42136edf9b1
github.com/davecgh/go-spew v1.1.1
github.com/deepmap/oapi-codegen v1.3.11 // indirect
......@@ -25,7 +28,7 @@ require (
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
github.com/facebookgo/structtag v0.0.0-20150214074306-217e25fb9691 // indirect
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect
github.com/fatih/color v1.7.0
github.com/fatih/color v1.9.0
github.com/go-macaron/binding v0.0.0-20190806013118-0b4f37bab25b
github.com/go-macaron/gzip v0.0.0-20160222043647-cad1c6580a07
github.com/go-macaron/session v0.0.0-20190805070824-1a3cdc6f5659
......@@ -38,57 +41,52 @@ require (
github.com/gosimple/slug v1.4.2
github.com/grafana/grafana-plugin-model v0.0.0-20190930120109-1fc953a61fb4
github.com/grafana/grafana-plugin-sdk-go v0.77.0
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/grafana/loki v1.6.0
github.com/hashicorp/go-hclog v0.12.2
github.com/hashicorp/go-plugin v1.2.2
github.com/hashicorp/go-version v1.1.0
github.com/hashicorp/go-version v1.2.0
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec
github.com/influxdata/influxdb-client-go/v2 v2.0.1
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
github.com/jmespath/go-jmespath v0.3.0
github.com/jung-kurt/gofpdf v1.10.1
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/klauspost/compress v1.4.1 // indirect
github.com/klauspost/cpuid v1.2.0 // indirect
github.com/lib/pq v1.2.0
github.com/lib/pq v1.3.0
github.com/linkedin/goavro/v2 v2.9.7
github.com/magefile/mage v1.9.0
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-sqlite3 v1.11.0
github.com/opentracing/opentracing-go v1.1.0
github.com/opentracing/opentracing-go v1.2.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.6.0
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.9.1
github.com/prometheus/common v0.10.0
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
github.com/robfig/cron/v3 v3.0.0
github.com/sergi/go-diff v1.0.0 // indirect
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
github.com/smartystreets/goconvey v1.6.4
github.com/stretchr/testify v1.5.1
github.com/teris-io/shortid v0.0.0-20171029131806-771a37caa5cf
github.com/timberio/go-datemath v0.1.1-0.20200323150745-74ddef604fff
github.com/ua-parser/uap-go v0.0.0-20190826212731-daf92ba38329
github.com/uber/jaeger-client-go v2.24.0+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/uber/jaeger-client-go v2.25.0+incompatible
github.com/unknwon/com v1.0.1
github.com/urfave/cli/v2 v2.1.1
github.com/xorcare/pointer v1.1.0
github.com/yudai/gojsondiff v1.0.0
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
go.uber.org/atomic v1.5.1 // indirect
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sys v0.0.0-20200812155832-6a926be9bd1d // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200708183856-df98bc6d456c // indirect
google.golang.org/grpc v1.29.1
google.golang.org/grpc v1.30.0
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/ini.v1 v1.46.0
gopkg.in/ini.v1 v1.51.0
gopkg.in/ldap.v3 v3.0.2
gopkg.in/macaron.v1 v1.3.9
gopkg.in/mail.v2 v2.3.1
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,6 +8,7 @@ import (
_ "github.com/gobwas/glob"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/services/licensing"
_ "github.com/grafana/loki/pkg/logproto"
_ "github.com/jung-kurt/gofpdf"
_ "github.com/linkedin/goavro/v2"
_ "github.com/pkg/errors"
......
package grpcplugin
import (
"fmt"
"io"
"io/ioutil"
"log"
glog "github.com/grafana/grafana/pkg/infra/log"
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-hclog"
)
type logWrapper struct {
Logger glog.Logger
name string
impliedArgs []interface{}
}
func formatArgs(args ...interface{}) []interface{} {
......@@ -34,31 +38,84 @@ func formatArgs(args ...interface{}) []interface{} {
return res
}
// Emit a message and key/value pairs at a provided log level
func (lw logWrapper) Log(level hclog.Level, msg string, args ...interface{}) {
switch level {
case hclog.Trace:
lw.Trace(msg, args...)
case hclog.Debug:
lw.Debug(msg, args...)
case hclog.Info:
lw.Info(msg, args...)
case hclog.Warn:
lw.Warn(msg, args...)
case hclog.Error:
lw.Error(msg, args...)
}
}
// Emit a message and key/value pairs at the TRACE level
func (lw logWrapper) Trace(msg string, args ...interface{}) {
lw.Logger.Debug(msg, formatArgs(args...)...)
}
// Emit a message and key/value pairs at the DEBUG level
func (lw logWrapper) Debug(msg string, args ...interface{}) {
lw.Logger.Debug(msg, formatArgs(args...)...)
}
// Emit a message and key/value pairs at the INFO level
func (lw logWrapper) Info(msg string, args ...interface{}) {
lw.Logger.Info(msg, formatArgs(args...)...)
}
// Emit a message and key/value pairs at the WARN level
func (lw logWrapper) Warn(msg string, args ...interface{}) {
lw.Logger.Warn(msg, formatArgs(args...)...)
}
// Emit a message and key/value pairs at the ERROR level
func (lw logWrapper) Error(msg string, args ...interface{}) {
lw.Logger.Error(msg, formatArgs(args...)...)
}
// Indicate if TRACE logs would be emitted.
func (lw logWrapper) IsTrace() bool { return true }
// Indicate if DEBUG logs would be emitted.
func (lw logWrapper) IsDebug() bool { return true }
// Indicate if INFO logs would be emitted.
func (lw logWrapper) IsInfo() bool { return true }
// Indicate if WARN logs would be emitted.
func (lw logWrapper) IsWarn() bool { return true }
// Indicate if ERROR logs would be emitted.
func (lw logWrapper) IsError() bool { return true }
// ImpliedArgs returns With key/value pairs
func (lw logWrapper) ImpliedArgs() []interface{} {
return lw.impliedArgs
}
// Creates a sublogger that will always have the given key/value pairs
func (lw logWrapper) With(args ...interface{}) hclog.Logger {
return logWrapper{Logger: lw.Logger.New(args...)}
return logWrapper{
Logger: lw.Logger.New(args...),
name: lw.name,
impliedArgs: args,
}
}
// Returns the Name of the logger
func (lw logWrapper) Name() string {
return lw.name
}
// Create a logger that will prepend the name string on the front of all messages.
// If the logger already has a name, the new value will be appended to the current
// name.
func (lw logWrapper) Named(name string) hclog.Logger {
if name == "stdio" {
// discard logs from stdio hashicorp/go-plugin gRPC service since
......@@ -67,21 +124,37 @@ func (lw logWrapper) Named(name string) hclog.Logger {
// discard warn log of "received EOF, stopping recv loop".
return hclog.NewNullLogger()
}
if lw.name != "" {
name = fmt.Sprintf("%s.%s", lw.name, name)
}
return logWrapper{
Logger: lw.Logger.New(),
name: name,
impliedArgs: lw.impliedArgs,
}
}
// Create a logger that will prepend the name string on the front of all messages.
// This sets the name of the logger to the value directly, unlike Named which honor
// the current name as well.
func (lw logWrapper) ResetNamed(name string) hclog.Logger {
return logWrapper{Logger: lw.Logger.New()}
return logWrapper{
Logger: lw.Logger.New(),
name: name,
impliedArgs: lw.impliedArgs,
}
}
// No-op. The wrapped logger implementation cannot update the level on the fly.
func (lw logWrapper) SetLevel(level hclog.Level) {}
// Return a value that conforms to the stdlib log.Logger interface
func (lw logWrapper) StandardLogger(ops *hclog.StandardLoggerOptions) *log.Logger {
return nil
}
func (lw logWrapper) SetLevel(level hclog.Level) {}
// Return a value that conforms to io.Writer, which can be passed into log.SetOutput()
func (lw logWrapper) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer {
return ioutil.Discard
......
......@@ -5,7 +5,6 @@ package setting
import (
"bytes"
"errors"
"fmt"
"net/http"
"net/url"
......@@ -1086,12 +1085,6 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
}
func valueAsString(section *ini.Section, keyName string, defaultValue string) (value string, err error) {
defer func() {
if err_ := recover(); err_ != nil {
err = errors.New("Invalid value for key '" + keyName + "' in configuration file")
}
}()
return section.Key(keyName).MustString(defaultValue), nil
}
......
......@@ -289,12 +289,6 @@ func TestLoadingSettings(t *testing.T) {
So(err, ShouldBeNil)
So(value, ShouldEqual, "default_url_val")
})
Convey("In case of panic - should return user-friendly error", func() {
value, err := valueAsString(iniFile.Section("server"), "root_url", "")
So(err.Error(), ShouldEqual, "Invalid value for key 'root_url' in configuration file")
So(value, ShouldEqual, "")
})
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment