From 281b71a8467b8643386a07211f18864b2b71bdec Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 16 Apr 2004 08:18:39 +0000 Subject: [PATCH] - use new logger interface - added support for log_level and log_file in configuration file --- helm/http_getter/http_getter.conf.xml.sample | 3 +++ helm/http_getter/main.ml | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/helm/http_getter/http_getter.conf.xml.sample b/helm/http_getter/http_getter.conf.xml.sample index 05eb13bb9..8551ff0e7 100644 --- a/helm/http_getter/http_getter.conf.xml.sample +++ b/helm/http_getter/http_getter.conf.xml.sample @@ -30,5 +30,8 @@ 58081 + + 1 + http_getter.log diff --git a/helm/http_getter/main.ml b/helm/http_getter/main.ml index 699c685bb..6a3ec6a0d 100644 --- a/helm/http_getter/main.ml +++ b/helm/http_getter/main.ml @@ -31,7 +31,6 @@ open Printf open Http_getter_common open Http_getter_misc open Http_getter_types -open Http_getter_debugger (* constants *) @@ -228,7 +227,7 @@ let return_list_servers outchan = (Http_getter.list_servers ())))) outchan -let log_failure msg = debug_print ("Request not fulfilled: " ^ msg) +let log_failure msg = Http_getter_logger.log ("Request not fulfilled: " ^ msg) (** given an action (i.e. a function which expects a logger and do something * using it as a logger), perform it sending its output incrementally to the @@ -254,8 +253,8 @@ let send_log_to ?prepend action outchan = let callback (req: Http_types.request) outchan = try - debug_print ("Connection from " ^ req#clientAddr); - debug_print ("Received request: " ^ req#path); + Http_getter_logger.log ("Connection from " ^ req#clientAddr); + Http_getter_logger.log ("Received request: " ^ req#path); (match req#path with | "/help" -> return_help outchan | "/getxml" -> @@ -309,7 +308,7 @@ let callback (req: Http_types.request) outchan = Http_daemon.respond ~body:Http_getter_const.empty_xml outchan | invalid_request -> Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan); - debug_print "Done!\n" + Http_getter_logger.log "Done!\n" with | Http_types.Param_not_found attr_name -> let msg = sprintf "Parameter '%s' is missing" attr_name in @@ -339,6 +338,10 @@ let callback (req: Http_types.request) outchan = let main () = Helm_registry.load_from configuration_file; + Http_getter_logger.set_log_level + (Helm_registry.get_opt_default Helm_registry.get_int 1 "getter.log_level"); + Http_getter_logger.set_log_file + (Helm_registry.get_opt Helm_registry.get_string "getter.log_file"); Http_getter_env.reload (); print_string (Http_getter_env.env_to_string ()); flush stdout; -- 2.39.2