-
Notifications
You must be signed in to change notification settings - Fork 4
/
circonus.go
45 lines (36 loc) · 1.07 KB
/
circonus.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright © 2019 Circonus, Inc. <support@circonus.com>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Package circonus contains methods for interfacing with circonus
package circonus
import (
"strings"
"github.com/circonus-labs/circonus-kubernetes-agent/internal/config/keys"
"github.com/rs/zerolog"
"github.com/spf13/viper"
)
// apiLogshim is used to satisfy apiclient Logger interface for retryable-http (avoiding ptr receiver issue)
type apiLogshim struct {
logh zerolog.Logger
}
func (l apiLogshim) Printf(fmt string, v ...interface{}) {
if strings.HasPrefix(fmt, "[DEBUG]") {
if !viper.GetBool(keys.APIDebug) {
return
}
}
l.logh.Printf(fmt, v...)
}
// submitLogshim is used to satisfy submission use of retryable-http Logger interface (avoiding ptr receiver issue)
type submitLogshim struct {
logh zerolog.Logger
}
func (l submitLogshim) Printf(fmt string, v ...interface{}) {
if strings.HasPrefix(fmt, "[DEBUG]") {
if e := l.logh.Debug(); !e.Enabled() {
return
}
}
l.logh.Printf(fmt, v...)
}