log: make it easier to add parameters to JSON logging
This commit is contained in:
parent
acbcb1ea9d
commit
e972f2c98a
3 changed files with 49 additions and 9 deletions
|
@ -1,6 +1,28 @@
|
|||
package fs
|
||||
|
||||
import "github.com/spf13/pflag"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Check it satisfies the interface
|
||||
var _ pflag.Value = (*LogLevel)(nil)
|
||||
var _ fmt.Stringer = LogValueItem{}
|
||||
|
||||
type withString struct{}
|
||||
|
||||
func (withString) String() string {
|
||||
return "hello"
|
||||
}
|
||||
|
||||
func TestLogValue(t *testing.T) {
|
||||
x := LogValue("x", 1)
|
||||
assert.Equal(t, "1", x.String())
|
||||
x = LogValue("x", withString{})
|
||||
assert.Equal(t, "hello", x.String())
|
||||
x = LogValueHide("x", withString{})
|
||||
assert.Equal(t, "", x.String())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue