Codebase list golang-github-go-kit-kit / 5316af2
Change default file key string to caller Will Faught 7 years ago
2 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
3838 return func(a *StdlibAdapter) { a.timestampKey = key }
3939 }
4040
41 // FileKey sets the key for the file and line field. By default, it's "file".
41 // FileKey sets the key for the file and line field. By default, it's "caller".
4242 func FileKey(key string) StdlibAdapterOption {
4343 return func(a *StdlibAdapter) { a.fileKey = key }
4444 }
5454 a := StdlibAdapter{
5555 Logger: logger,
5656 timestampKey: "ts",
57 fileKey: "file",
57 fileKey: "caller",
5858 messageKey: "msg",
5959 }
6060 for _, option := range options {
3434 log.Ldate: "ts=" + date + " msg=hello\n",
3535 log.Ltime: "ts=" + time + " msg=hello\n",
3636 log.Ldate | log.Ltime: "ts=\"" + date + " " + time + "\" msg=hello\n",
37 log.Lshortfile: "file=stdlib_test.go:44 msg=hello\n",
38 log.Lshortfile | log.Ldate: "ts=" + date + " file=stdlib_test.go:44 msg=hello\n",
39 log.Lshortfile | log.Ldate | log.Ltime: "ts=\"" + date + " " + time + "\" file=stdlib_test.go:44 msg=hello\n",
37 log.Lshortfile: "caller=stdlib_test.go:44 msg=hello\n",
38 log.Lshortfile | log.Ldate: "ts=" + date + " caller=stdlib_test.go:44 msg=hello\n",
39 log.Lshortfile | log.Ldate | log.Ltime: "ts=\"" + date + " " + time + "\" caller=stdlib_test.go:44 msg=hello\n",
4040 } {
4141 buf.Reset()
4242 stdlog.SetFlags(flag)
5757 "2009/01/23 01:23:23: hello": "ts=\"2009/01/23 01:23:23\" msg=hello\n",
5858 "01:23:23: hello": "ts=01:23:23 msg=hello\n",
5959 "2009/01/23 01:23:23.123123: hello": "ts=\"2009/01/23 01:23:23.123123\" msg=hello\n",
60 "2009/01/23 01:23:23.123123 /a/b/c/d.go:23: hello": "ts=\"2009/01/23 01:23:23.123123\" file=/a/b/c/d.go:23 msg=hello\n",
61 "01:23:23.123123 /a/b/c/d.go:23: hello": "ts=01:23:23.123123 file=/a/b/c/d.go:23 msg=hello\n",
62 "2009/01/23 01:23:23 /a/b/c/d.go:23: hello": "ts=\"2009/01/23 01:23:23\" file=/a/b/c/d.go:23 msg=hello\n",
63 "2009/01/23 /a/b/c/d.go:23: hello": "ts=2009/01/23 file=/a/b/c/d.go:23 msg=hello\n",
64 "/a/b/c/d.go:23: hello": "file=/a/b/c/d.go:23 msg=hello\n",
60 "2009/01/23 01:23:23.123123 /a/b/c/d.go:23: hello": "ts=\"2009/01/23 01:23:23.123123\" caller=/a/b/c/d.go:23 msg=hello\n",
61 "01:23:23.123123 /a/b/c/d.go:23: hello": "ts=01:23:23.123123 caller=/a/b/c/d.go:23 msg=hello\n",
62 "2009/01/23 01:23:23 /a/b/c/d.go:23: hello": "ts=\"2009/01/23 01:23:23\" caller=/a/b/c/d.go:23 msg=hello\n",
63 "2009/01/23 /a/b/c/d.go:23: hello": "ts=2009/01/23 caller=/a/b/c/d.go:23 msg=hello\n",
64 "/a/b/c/d.go:23: hello": "caller=/a/b/c/d.go:23 msg=hello\n",
6565 } {
6666 buf.Reset()
6767 fmt.Fprint(writer, input)