switch to go-kit/log (#1575)
Signed-off-by: yeya24 <yb532204897@gmail.com>
This commit is contained in:
parent
a80b7d0bc5
commit
2477c5c67d
158 changed files with 3434 additions and 4636 deletions
|
|
@ -20,10 +20,12 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/prometheus/common/log"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
"github.com/prometheus/common/promlog"
|
||||
"github.com/prometheus/common/promlog/flag"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
type collectorAdapter struct {
|
||||
|
|
@ -39,8 +41,7 @@ func (a collectorAdapter) Describe(ch chan<- *prometheus.Desc) {
|
|||
|
||||
// Collect implements the prometheus.Collector interface.
|
||||
func (a collectorAdapter) Collect(ch chan<- prometheus.Metric) {
|
||||
err := a.Update(ch)
|
||||
if err != nil {
|
||||
if err := a.Update(ch); err != nil {
|
||||
panic(fmt.Sprintf("failed to update collector: %v", err))
|
||||
}
|
||||
}
|
||||
|
|
@ -95,15 +96,16 @@ func TestTextfileCollector(t *testing.T) {
|
|||
for i, test := range tests {
|
||||
mtime := 1.0
|
||||
c := &textFileCollector{
|
||||
path: test.path,
|
||||
mtime: &mtime,
|
||||
path: test.path,
|
||||
mtime: &mtime,
|
||||
logger: log.NewNopLogger(),
|
||||
}
|
||||
|
||||
// Suppress a log message about `nonexistent_path` not existing, this is
|
||||
// expected and clutters the test output.
|
||||
log.AddFlags(kingpin.CommandLine)
|
||||
_, err := kingpin.CommandLine.Parse([]string{"--log.level", "fatal"})
|
||||
if err != nil {
|
||||
promlogConfig := &promlog.Config{}
|
||||
flag.AddFlags(kingpin.CommandLine, promlogConfig)
|
||||
if _, err := kingpin.CommandLine.Parse([]string{"--log.level", "debug"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue