Skip to content

Commit fc3547b

Browse files
committed
Deflatemod: Add debug logs
1 parent b3c8011 commit fc3547b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/extensions/deflatemod.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ let write_int32 buf offset n =
6969
(Char.chr (Int32.to_int (Int32.shift_right_logical n (8 * i)) land 0xff))
7070
done
7171

72-
let compress_flush oz used_out = oz.flush (Bytes.sub_string oz.buf 0 used_out)
72+
let compress_flush oz used_out =
73+
Logs.debug ~src:section (fun fmt -> fmt "Flushing %d bytes" used_out);
74+
oz.flush (Bytes.sub_string oz.buf 0 used_out)
7375

7476
(* gzip trailer *)
7577
let write_trailer oz =
@@ -95,6 +97,7 @@ let rec compress_output oz inbuf pos len =
9597
compress_output oz inbuf (pos + used_in) (len - used_in)
9698

9799
let rec compress_finish oz =
100+
Logs.debug ~src:section (fun fmt -> fmt "Finishing");
98101
(* loop until there is nothing left to compress and flush *)
99102
let finished, (_ : int), used_out =
100103
Zlib.deflate oz.stream oz.buf 0 0 oz.buf 0 (Bytes.length oz.buf)
@@ -124,6 +127,7 @@ let compress_body deflate body =
124127
>>= fun () ->
125128
compress_finish oz >>= fun () ->
126129
(if deflate then Lwt.return_unit else write_trailer oz) >>= fun () ->
130+
Logs.debug ~src:section (fun fmt -> fmt "Close stream");
127131
(try Zlib.deflate_end zstream
128132
with
129133
(* ignore errors, deflate_end cleans everything anyway *)

0 commit comments

Comments
 (0)