Commit 03eda652 authored by Alexandre Viau's avatar Alexandre Viau

New upstream version 2.14

parent 7f7e59c0
......@@ -3,11 +3,8 @@ go_import_path: github.com/inconshreveable/log15
sudo: false
go:
- 1.3
- 1.4
- 1.5
- 1.6
- 1.7
- 1.8
- 1.9
- tip
- 1.7.x
- 1.8.x
- 1.9.x
- 1.10.x
- master
......@@ -24,5 +24,6 @@ Sean Chittenden <sean@chittenden.org>
Spencer Nelson <s@spenczar.com>
Tomasz Grodzki <tg@users.noreply.github.com>
Trevor Gattis <github@trevorgattis.com>
Varun Agrawal <vagrawal@pindropsecurity.com>
Vincent Vanackere <vincent.vanackere@gmail.com>
Will McGovern <will@brkt.com>
......@@ -39,7 +39,7 @@ func (f formatFunc) Format(r *Record) []byte {
// a terminal with color-coded level output and terser human friendly timestamp.
// This format should only be used for interactive programs or while developing.
//
// [TIME] [LEVEL] MESAGE key=value key=value ...
// [TIME] [LEVEL] MESSAGE key=value key=value ...
//
// Example:
//
......@@ -195,9 +195,12 @@ func formatShared(value interface{}) (result interface{}) {
func formatJSONValue(value interface{}) interface{} {
value = formatShared(value)
switch value.(type) {
case int, int8, int16, int32, int64, float32, float64, uint, uint8, uint16, uint32, uint64, string:
return value
case interface{}, map[string]interface{}, []interface{}:
return value
default:
return fmt.Sprintf("%+v", value)
}
......
......@@ -115,6 +115,34 @@ func TestJson(t *testing.T) {
validate("lvl", "eror")
}
func TestJSONMap(t *testing.T) {
m := map[string]interface{}{
"name": "gopher",
"age": float64(5),
"language": "go",
}
l, buf := testFormatter(JsonFormat())
l.Error("logging structs", "struct", m)
var v map[string]interface{}
decoder := json.NewDecoder(buf)
if err := decoder.Decode(&v); err != nil {
t.Fatalf("Error decoding JSON: %v", v)
}
checkMap := func(key string, expected interface{}) {
if m[key] != expected {
t.Fatalf("Got %v expected %v for %v", m[key], expected, key)
}
}
mv := v["struct"].(map[string]interface{})
checkMap("name", mv["name"])
checkMap("age", mv["age"])
checkMap("language", mv["language"])
}
type testtype struct {
name string
}
......
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