]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/uwobo/src/ocaml/uwobo_logger.ml
- export level and levelNo with methods
[helm.git] / helm / uwobo / src / ocaml / uwobo_logger.ml
index c2f69eecc80213b415b572450854d297c9c9e472..3a197041c220a39ba54992a4de800c314f82667b 100644 (file)
@@ -57,18 +57,22 @@ class sysLogger ?(level: priority = `Notice) () =
       print_endline (sprintf "Logger started with level %s" (string_of_priority level))
     val level_no = int_of_priority level
     val mutable enabled = false
+    method level = level
+    method levelNo = level_no
     method enable = self#doCritical (lazy (enabled <- true))
     method disable = self#doCritical (lazy (enabled <- false))
     method log (prio: priority) msg =
       self#doCritical (lazy (
         if enabled && (int_of_priority prio <= level_no) then
-          prerr_endline (sprintf ("%s: %s") (string_of_priority prio) msg)
+          prerr_endline (sprintf ("[UWOBO] %s: %s") (string_of_priority prio) msg)
       ))
   end
 
   (** non thread safe, a processingLogger is usually instantied locally for each
   thread *)
-class processingLogger () =
+class processingLogger =
+  let html_escape = Netencoding.Html.encode ~in_enc:`Enc_iso88591 () in
+  fun () ->
   object
     val mutable log_lines: string list = []
     method log msg = log_lines <- msg :: log_lines
@@ -76,8 +80,6 @@ class processingLogger () =
     method asHtml =
       sprintf
         "<html><body>\n%s\n</body></html>"
-        (String.concat
-          "<br />\n"
-          (List.map (Netencoding.Url.encode ~plus:false) (List.rev log_lines)))
+        (String.concat "<br />\n" (List.map html_escape (List.rev log_lines)))
   end