From 3579acf4950fc4f9a4ddc3e2cfca372d67cba712 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Sat, 15 Mar 2003 18:35:35 +0000 Subject: [PATCH] - added support for "formatted" log messages, mainly * method logBold * method logEmph used to log error and debugging messages to be output on HTML pages --- helm/uwobo/uwobo_logger.ml | 27 +++++++++++++++++++++++---- helm/uwobo/uwobo_logger.mli | 2 ++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/helm/uwobo/uwobo_logger.ml b/helm/uwobo/uwobo_logger.ml index bbd7e03f1..0b557f114 100644 --- a/helm/uwobo/uwobo_logger.ml +++ b/helm/uwobo/uwobo_logger.ml @@ -71,18 +71,37 @@ class sysLogger ?(level: priority = `Notice) ?(outchan = stderr) () = end end +type lineType = + | Line of string (** normal line *) + | LineBold of string (** bold line *) + | LineEmph of string (** emph line *) +;; + (** non thread safe, a processingLogger is usually instantied locally for each thread *) class processingLogger = let html_escape = Netencoding.Html.encode ~in_enc:`Enc_iso88591 () in + let html_of_line = function + | Line l -> html_escape l + | LineBold l -> "" ^ html_escape l ^ "" + | LineEmph l -> "" ^ html_escape l ^ "" + in + let text_of_line = function + | Line l -> l + | LineBold l -> l + | LineEmph l -> l + in fun () -> object - val mutable log_lines: string list = [] - method log msg = log_lines <- msg :: log_lines - method asText = String.concat "\n" (List.rev log_lines) + val mutable log_lines = [] + method log msg = log_lines <- Line msg :: log_lines + method logBold msg = log_lines <- LineBold msg :: log_lines + method logEmph msg = log_lines <- LineEmph msg :: log_lines + method asText = + String.concat "\n" (List.rev (List.map text_of_line log_lines)) method asHtml = sprintf "\n%s\n" - (String.concat "
\n" (List.map html_escape (List.rev log_lines))) + (String.concat "
\n" (List.map html_of_line (List.rev log_lines))) end diff --git a/helm/uwobo/uwobo_logger.mli b/helm/uwobo/uwobo_logger.mli index b05cdda08..2a1a6cd53 100644 --- a/helm/uwobo/uwobo_logger.mli +++ b/helm/uwobo/uwobo_logger.mli @@ -61,6 +61,8 @@ class processingLogger: unit -> object method log: string -> unit + method logBold: string -> unit + method logEmph: string -> unit method asText: string method asHtml: string end -- 2.39.2