X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fuwobo%2Fuwobo_logger.ml;h=0b557f114db71b1465daaf0ce14f632fff36c59c;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=bbd7e03f1280e6b97189181caae06f77da4e3967;hpb=47b0c2c1b421b62302b1957954912b4c0dfba9fa;p=helm.git 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