Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct { Logger *loggerPkg.Logger PanicHandler func(*goa.Context) ShouldLogReqBody func(*goa.Context) bool ShouldLogRespBody func(*goa.Context) bool }
Example ¶
ts, buf := startTestServer() defer ts.Close() if _, err := http.Post( ts.URL+"?a=b&c=d", "application/json", strings.NewReader("[0,1,2]"), ); err != nil { log.Panic(err) } printLog(buf)
Output: {"code":"ok","message":"good"} 31 agent: "Go-http-client/1.1" host: "127.0.0.1:3000" ip: "127.0.0.1" level: "info" method: "POST" path: "/" rawQuery: "a=b&c=d" refer: "" reqBody: "[0,1,2]" reqBodySize: 7 requestId: "" respBody: "{\"code\":\"ok\",\"message\":\"good\"}\n" respBodySize: 31 session: "session-data" status: 200
Example (Debug) ¶
ts, buf := startTestServer() defer ts.Close() if _, err := http.Post( ts.URL+"?a=b&c=d&_debug", "application/json", strings.NewReader("[0,1,2]"), ); err != nil { log.Panic(err) } printLog(buf)
Output: {"code":"ok","message":"good"} 31 agent: "Go-http-client/1.1" host: "127.0.0.1:3000" ip: "127.0.0.1" level: "info" method: "POST" path: "/" rawQuery: "a=b&c=d&_debug" refer: "" reqBody: "[0,1,2]" reqBodySize: 7 requestId: "" respBody: "{\"code\":\"ok\",\"message\":\"good\"}\n" respBodySize: 31 session: "session-data" status: 200
Example (Panic) ¶
ts, buf := startTestServer() defer ts.Close() if _, err := http.Get(ts.URL + "/panic?_debug"); err != nil { log.Panic(err) } printLog(buf)
Output: agent: "Go-http-client/1.1" host: "127.0.0.1:3000" ip: "127.0.0.1" level: "recover" method: "GET" msg: "crash" path: "/panic" rawQuery: "_debug" refer: "" reqBody: "" reqBodySize: 0 requestId: "" respBody: "{\"code\":\"server-err\",\"message\":\"Fatal Server Error.\"}\n" respBodySize: 54 status: 500 stack: log.Panic
Click to show internal directories.
Click to hide internal directories.