backend requirements onthe xustomer app
This commit is contained in:
@@ -19,21 +19,33 @@ func ZapLogger() fiber.Handler {
|
||||
method := c.Method()
|
||||
path := c.Path()
|
||||
|
||||
// Client identity and the request id travel with every log line.
|
||||
//
|
||||
// X-Client / X-Platform are what the customer app sends
|
||||
// ("doormile-cx/1.0.0+12", "android"), and they are the only way to
|
||||
// answer "is this failing on one build or everywhere" — which is the
|
||||
// first question asked when an app-side report arrives. The request id
|
||||
// is what correlates a customer saying "it failed" with the line that
|
||||
// recorded the real error behind the customer-safe message.
|
||||
//
|
||||
// Recorded as empty rather than omitted when absent, so a caller that
|
||||
// sends nothing is visibly a caller that sends nothing.
|
||||
fields := []interface{}{
|
||||
"method", method,
|
||||
"path", path,
|
||||
"status", status,
|
||||
"latency", latency,
|
||||
"client", c.Get("X-Client"),
|
||||
"platform", c.Get("X-Platform"),
|
||||
}
|
||||
if id, ok := c.Locals("requestid").(string); ok && id != "" {
|
||||
fields = append(fields, "requestid", id)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
utils.Error("API request error",
|
||||
"method", method,
|
||||
"path", path,
|
||||
"status", status,
|
||||
"latency", latency,
|
||||
"error", err.Error(),
|
||||
)
|
||||
utils.Error("API request error", append(fields, "error", err.Error())...)
|
||||
} else {
|
||||
utils.Info("API request success",
|
||||
"method", method,
|
||||
"path", path,
|
||||
"status", status,
|
||||
"latency", latency,
|
||||
)
|
||||
utils.Info("API request success", fields...)
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user