From 285f5b4454e34023e57b21d4b6b908979aa79a69 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 10 Jan 2003 09:15:18 +0000 Subject: [PATCH] - export level and levelNo with methods - escape also spaces with '+' in html escaping --- helm/uwobo/src/ocaml/uwobo_logger.ml | 12 +++++++----- helm/uwobo/src/ocaml/uwobo_logger.mli | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/helm/uwobo/src/ocaml/uwobo_logger.ml b/helm/uwobo/src/ocaml/uwobo_logger.ml index c2f69eecc..3a197041c 100644 --- a/helm/uwobo/src/ocaml/uwobo_logger.ml +++ b/helm/uwobo/src/ocaml/uwobo_logger.ml @@ -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 "\n%s\n" - (String.concat - "
\n" - (List.map (Netencoding.Url.encode ~plus:false) (List.rev log_lines))) + (String.concat "
\n" (List.map html_escape (List.rev log_lines))) end diff --git a/helm/uwobo/src/ocaml/uwobo_logger.mli b/helm/uwobo/src/ocaml/uwobo_logger.mli index f98c810e2..a250f655d 100644 --- a/helm/uwobo/src/ocaml/uwobo_logger.mli +++ b/helm/uwobo/src/ocaml/uwobo_logger.mli @@ -41,6 +41,8 @@ class sysLogger: ?level: priority -> unit -> object + method level: priority + method levelNo: int (** enable logging, by default logging is disabled *) method enable: unit (** disable logging *) -- 2.39.2