log reporter style renderer
This commit is contained in:
parent
7a5fe47162
commit
f394c24e3b
3 changed files with 47 additions and 58 deletions
|
|
@ -1,9 +1,9 @@
|
|||
let pp_status ppf status =
|
||||
match status with
|
||||
| #H2.Status.standard as status ->
|
||||
Fmt.pf ppf "HTTP [%d %s]" (H2.Status.to_code status)
|
||||
Fmt.pf ppf "HTTP status: %d %s" (H2.Status.to_code status)
|
||||
(H2.Status.default_reason_phrase status)
|
||||
| _ -> Fmt.pf ppf "HTTP [%d]" (H2.Status.to_code status)
|
||||
| _ -> Fmt.pf ppf "HTTP %d" (H2.Status.to_code status)
|
||||
|
||||
let empty status =
|
||||
Logs.info (fun m -> m "%a" pp_status status);
|
||||
|
|
@ -41,10 +41,8 @@ let map_err_status err =
|
|||
let error req err =
|
||||
let status = map_err_status err in
|
||||
let hint = Result.err_to_string err in
|
||||
let log_lvl =
|
||||
if H2.Status.is_server_error status then Logs.Error else Logs.Warning
|
||||
in
|
||||
Logs.msg log_lvl (fun m -> m "%a %s" pp_status status hint);
|
||||
let log = if H2.Status.is_server_error status then Logs.err else Logs.warn in
|
||||
log (fun m -> m "%a %s" pp_status status hint);
|
||||
let body = Api.ErrorDetail.make ~hint (-1) in
|
||||
respond_json req Api.ErrorDetail.jsont status body
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue