Skip to content

Commit 3b1f879

Browse files
committed
fix: lower logs to trace
1 parent d58328f commit 3b1f879

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

blink/connection.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,26 @@ let stream (Conn ({ headers; reader; state; protocol; _ } as conn)) =
9191
well.
9292
*)
9393
| Unread ->
94-
debug (fun f -> f "Beginning stream on unread connection...");
94+
trace (fun f -> f "Beginning stream on unread connection...");
9595
let* status, headers, body_prefix =
9696
Protocol.Response.read_header reader
9797
in
98-
debug (fun f -> f "-> status: %a" Http.Status.pp status);
99-
debug (fun f ->
98+
trace (fun f -> f "-> status: %a" Http.Status.pp status);
99+
trace (fun f ->
100100
f "-> body prefix size: %d" (Bytestring.length body_prefix));
101101
let content_length =
102102
match Http.Header.get_content_range headers with
103103
| None -> `unknown
104104
| Some size -> `fixed (Int64.to_int size)
105105
in
106-
debug (fun f ->
106+
trace (fun f ->
107107
f "-> expected content length: %a" pp_measure content_length);
108108
let body_remaining =
109109
match content_length with
110110
| `unknown | `fixed 0 -> content_length
111111
| `fixed size -> `fixed (size - Bytestring.length body_prefix)
112112
in
113-
debug (fun f -> f "-> remaining body: %a" pp_measure body_remaining);
113+
trace (fun f -> f "-> remaining body: %a" pp_measure body_remaining);
114114

115115
let messages = [ `Status status; `Headers headers ] in
116116

@@ -140,8 +140,8 @@ let stream (Conn ({ headers; reader; state; protocol; _ } as conn)) =
140140
| More { body_remaining = `fixed 0; _ } ->
141141
Ok (Conn { conn with state = Done }, [ `Done ])
142142
| More { body_remaining; body_prefix } -> (
143-
debug (fun f -> f "Continuing stream on connection...");
144-
debug (fun f -> f "-> body_remaining: %a" pp_measure body_remaining);
143+
trace (fun f -> f "Continuing stream on connection...");
144+
trace (fun f -> f "-> body_remaining: %a" pp_measure body_remaining);
145145
match
146146
let body_remaining = measure_to_int body_remaining in
147147
Protocol.Response.read_body ~buffer:body_prefix ~headers ~body_remaining
@@ -178,7 +178,7 @@ let messages ?(on_message = fun _ -> ()) conn =
178178
in
179179
let* conn, messages = consume_stream conn [] in
180180
let messages = List.rev messages in
181-
debug (fun f ->
181+
trace (fun f ->
182182
f "collected %d messages:\n%a" (List.length messages) Msg.pp_messages
183183
messages);
184184
Ok (conn, messages)

blink/http1.ml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,48 +52,48 @@ module Response = struct
5252
let rec read_body ~buffer ~headers ~body_remaining reader =
5353
match Http.Header.get_transfer_encoding headers with
5454
| Http.Transfer.Chunked -> (
55-
debug (fun f -> f "Reading chunked body");
56-
debug (fun f -> f "-> body_remaining: %d" body_remaining);
55+
trace (fun f -> f "Reading chunked body");
56+
trace (fun f -> f "-> body_remaining: %d" body_remaining);
5757
match read_chunked_body ~buffer reader with
5858
| Ok `no_more_chunks -> `finished Bytestring.empty
5959
| Ok (`chunk (body, buffer)) -> `continue (body, buffer)
6060
| Error reason -> `error reason)
6161
| _ -> (
62-
debug (fun f -> f "reading content-length body");
62+
trace (fun f -> f "reading content-length body");
6363
match read_content_length_body reader buffer body_remaining with
6464
| Ok (body, buffer, body_remaining) ->
65-
debug (fun f ->
65+
trace (fun f ->
6666
f "read content_length body: body_remaning=%d buffer=%d"
6767
body_remaining (Bytestring.length buffer));
6868
if body_remaining = 0 && Bytestring.length buffer = 0 then (
69-
debug (fun f -> f "read content_length body: ok");
69+
trace (fun f -> f "read content_length body: ok");
7070
`finished body)
7171
else (
72-
debug (fun f -> f "read content_length body: more");
72+
trace (fun f -> f "read content_length body: more");
7373
`continue (body, buffer))
7474
| Error reason -> `error reason)
7575

7676
and read_chunked_body ~buffer reader =
7777
match split buffer with
7878
| [ zero; _ ] when String.equal (Bytestring.to_string zero) "0" ->
79-
debug (fun f -> f "read_chunked_body: last chunk!");
79+
trace (fun f -> f "read_chunked_body: last chunk!");
8080
Ok `no_more_chunks
8181
| [ chunk_size; chunk_data ] -> (
8282
let chunk_size =
8383
Int64.(of_string ("0x" ^ Bytestring.to_string chunk_size) |> to_int)
8484
in
85-
debug (fun f -> f "read_chunked_body: chunk_size=%d" chunk_size);
85+
trace (fun f -> f "read_chunked_body: chunk_size=%d" chunk_size);
8686
let binstr_data = Bytestring.to_string chunk_data in
87-
debug (fun f ->
87+
trace (fun f ->
8888
f "read_chunked_body: (%d bytes)" (String.length binstr_data));
8989
let binstr_data = binstr_data |> Bitstring.bitstring_of_string in
9090
match%bitstring binstr_data with
9191
| {| full_chunk : (chunk_size * 8) : string ;
9292
"\r\n" : 2 * 8 : string ;
9393
rest : -1 : bitstring |}
9494
->
95-
debug (fun f -> f "read_chunked_body: read full chunk");
96-
debug (fun f ->
95+
trace (fun f -> f "read_chunked_body: read full chunk");
96+
trace (fun f ->
9797
f "read_chunked_body: rest=%d" (Bitstring.bitstring_length rest));
9898
let rest =
9999
Bytestring.of_string (Bitstring.string_of_bitstring rest)
@@ -102,38 +102,38 @@ module Response = struct
102102
Ok (`chunk (full_chunk, rest))
103103
| {| _ |} ->
104104
let left_to_read = chunk_size - Bytestring.length chunk_data + 2 in
105-
debug (fun f ->
105+
trace (fun f ->
106106
f "read_chunked_body: reading more data left_to_read=%d"
107107
left_to_read);
108108
let* chunk = read ~to_read:left_to_read reader in
109109
let buffer = Bytestring.join buffer chunk in
110110
read_chunked_body ~buffer reader)
111111
| _ ->
112-
debug (fun f -> f "read_chunked_body: need more data");
112+
trace (fun f -> f "read_chunked_body: need more data");
113113
let* chunk = Bytestring.with_bytes (fun buf -> IO.read reader buf) in
114114
let buffer = Bytestring.join buffer chunk in
115115
read_chunked_body ~buffer reader
116116

117117
and read_content_length_body reader buffer body_remaining =
118118
let limit = body_remaining in
119119
let to_read = limit - Bytestring.length buffer in
120-
debug (fun f ->
120+
trace (fun f ->
121121
f "read_content_length_body: up to limit=%d with preread_buffer=%d"
122122
limit (Bytestring.length buffer));
123123
match body_remaining with
124124
| 0 when Bytestring.length buffer >= limit ->
125-
debug (fun f -> f "read_content_length_body: can answer with buffer");
125+
trace (fun f -> f "read_content_length_body: can answer with buffer");
126126
(* let len = Int.min limit (Bytestring.length buffer) in *)
127127
(* let body = Bytestring.sub ~off:0 ~len buffer in *)
128128
Ok (buffer, Bytestring.empty, 0)
129129
| n when n < 0 || to_read < 0 ->
130-
debug (fun f -> f "read_content_length_body: excess body");
130+
trace (fun f -> f "read_content_length_body: excess body");
131131
Error `Excess_body_read
132132
| remaining_bytes ->
133133
let to_read =
134134
Int.min (limit - Bytestring.length buffer) remaining_bytes
135135
in
136-
debug (fun f -> f "read_content_length_body: need to read %d" to_read);
136+
trace (fun f -> f "read_content_length_body: need to read %d" to_read);
137137
let* chunk = read ~to_read reader in
138138
let body = Bytestring.join buffer chunk in
139139
let body_remaining = remaining_bytes - Bytestring.length body in
@@ -143,15 +143,15 @@ module Response = struct
143143
if to_read = 0 then Ok buffer
144144
else
145145
let buf = Bytes.create to_read in
146-
debug (fun f -> f "reading to_read=%d" to_read);
146+
trace (fun f -> f "reading to_read=%d" to_read);
147147
let* len = IO.read reader buf in
148148
let chunk =
149149
Bytestring.of_string (Bytes.unsafe_to_string (Bytes.sub buf 0 len))
150150
in
151151
let remaining_bytes = to_read - Bytestring.length chunk in
152152
let buffer = Bytestring.join buffer chunk in
153-
debug (fun f -> f "read: remaining_bytes %d" remaining_bytes);
154-
debug (fun f -> f "read: buffer=%d" (Bytestring.length buffer));
153+
trace (fun f -> f "read: remaining_bytes %d" remaining_bytes);
154+
trace (fun f -> f "read: buffer=%d" (Bytestring.length buffer));
155155
if remaining_bytes > 0 then read ~to_read:remaining_bytes ~buffer reader
156156
else Ok buffer
157157

0 commit comments

Comments
 (0)