(e loggedRequest)
| 220 | } |
| 221 | |
| 222 | func formatRequest(e loggedRequest) string { |
| 223 | var b strings.Builder |
| 224 | fmt.Fprintf(&b, "%d. %s", e.Seq, displayName(e)) |
| 225 | if e.RawQuery != "" { |
| 226 | b.WriteString("?" + e.RawQuery) |
| 227 | } |
| 228 | if e.GraphQL != nil && len(e.GraphQL.Variables) > 0 { |
| 229 | b.WriteString(" " + truncate(compactJSON(e.GraphQL.Variables), maxShownBody)) |
| 230 | } |
| 231 | if e.Body != "" { |
| 232 | b.WriteString(" body " + truncate(compactJSON([]byte(e.Body)), maxShownBody)) |
| 233 | } |
| 234 | if e.RawBody != nil { |
| 235 | b.WriteString(" raw body " + rawBodySummary(*e.RawBody)) |
| 236 | } |
| 237 | switch { |
| 238 | case e.Git != nil: |
| 239 | if e.Method == "SSH" { |
| 240 | fmt.Fprintf(&b, " -> %s, exit code %d", e.Git.Service, e.Git.ExitCode) |
| 241 | } else { |
| 242 | fmt.Fprintf(&b, " -> %d, %s", e.Status, e.Git.Service) |
| 243 | } |
| 244 | if e.Git.Error != "" { |
| 245 | b.WriteString(" [" + e.Git.Error + "]") |
| 246 | } |
| 247 | case e.Blocked: |
| 248 | b.WriteString(" -> blocked") |
| 249 | case e.TLSError != "": |
| 250 | b.WriteString(" -> TLS handshake failed") |
| 251 | case e.Matched: |
| 252 | fmt.Fprintf(&b, " -> %d, response %d of %d", e.Status, e.Response, e.Responses) |
| 253 | default: |
| 254 | fmt.Fprintf(&b, " -> %d, no response stored", e.Status) |
| 255 | } |
| 256 | if e.OffSchema { |
| 257 | b.WriteString(" [off-schema]") |
| 258 | } |
| 259 | if n := len(e.SchemaProblems); n > 0 { |
| 260 | fmt.Fprintf(&b, " [%s]", plural(n, "schema problem")) |
| 261 | } |
| 262 | if n := len(e.QueryProblems); n > 0 { |
| 263 | fmt.Fprintf(&b, " [query: %s]", plural(n, "schema problem")) |
| 264 | } |
| 265 | if e.SchemaNote != "" { |
| 266 | fmt.Fprintf(&b, " [not checked: %s]", e.SchemaNote) |
| 267 | } |
| 268 | return b.String() |
| 269 | } |
| 270 | |
| 271 | func plural(n int, noun string) string { |
| 272 | if n == 1 { |
no test coverage detected