]> matita.cs.unibo.it Git - helm.git/commitdiff
- added support for "formatted" log messages, mainly
authorStefano Zacchiroli <zack@upsilon.cc>
Sat, 15 Mar 2003 18:35:35 +0000 (18:35 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Sat, 15 Mar 2003 18:35:35 +0000 (18:35 +0000)
  * method logBold
  * method logEmph
  used to log error and debugging messages to be output on HTML pages

helm/uwobo/uwobo_logger.ml
helm/uwobo/uwobo_logger.mli

index bbd7e03f1280e6b97189181caae06f77da4e3967..0b557f114db71b1465daaf0ce14f632fff36c59c 100644 (file)
@@ -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 -> "<b>" ^ html_escape l ^ "</b>"
+    | LineEmph l -> "<em>" ^ html_escape l ^ "</em>"
+  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
         "<html><body>\n%s\n</body></html>"
-        (String.concat "<br />\n" (List.map html_escape (List.rev log_lines)))
+        (String.concat "<br />\n" (List.map html_of_line (List.rev log_lines)))
   end
 
index b05cdda08a8a1898d6f5c7c82cb0d838977d0f68..2a1a6cd53890545d30dfc44805360c720a7c7dec 100644 (file)
@@ -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