+let log_failure msg = Http_getter_logger.log ("Request not fulfilled: " ^ msg)
+
+ (** given an action (i.e. a function which expects a logger and do something
+ * using it as a logger), perform it sending its output incrementally to the
+ * given output channel. Response is sent embedded in an HTML document.
+ * Channel is closed afterwards. *)
+let send_log_to ?prepend action outchan =
+ Http_daemon.send_basic_headers ~code:200 outchan;
+ Http_daemon.send_header "Content-Type" "text/html" outchan;
+ Http_daemon.send_CRLF outchan;
+ output_string outchan "<html><body>\n"; flush outchan;
+ (match prepend with
+ | None -> ()
+ | Some text -> output_string outchan text; flush outchan);
+ let logger tag =
+ output_string outchan (HelmLogger.html_of_html_tag tag);
+ flush outchan
+ in
+ action logger;
+ output_string outchan "\n</body></html>";
+ close_out outchan
+