From d6cb4446b6c5653dcdfb555959e388ef1c4c6411 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Sat, 15 Mar 2003 18:52:50 +0000 Subject: [PATCH] - added support for environment specified log file using variable UWOBO_LOG_FILE --- helm/uwobo/uwobo.ml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/helm/uwobo/uwobo.ml b/helm/uwobo/uwobo.ml index 6b18f8bdd..a88f9484f 100644 --- a/helm/uwobo/uwobo.ml +++ b/helm/uwobo/uwobo.ml @@ -30,19 +30,22 @@ open Printf;; open Uwobo_common;; (* debugging settings *) -let debug = false;; -let debug_level = `Notice;; -let debug_print s = if debug then prerr_endline s;; -Http_common.debug := false;; -let logfile = Some "uwobo.log";; (* relative to execution dir *) -let logfile_perm = 0o640;; +let debug = false ;; +let debug_level = `Notice ;; +let debug_print s = if debug then prerr_endline s ;; +Http_common.debug := false ;; (* other settings *) -let daemon_name = "UWOBO OCaml";; -let default_port = 58080;; -let port_env_var = "UWOBO_PORT";; -let default_media_type = "text/html";; -let default_encoding = "utf8";; +let daemon_name = "UWOBO OCaml" ;; +let default_log_file = "uwobo.log" ;; (* relative to execution dir *) +let default_port = 58080 ;; +let port_env_var = "UWOBO_PORT" ;; +let default_media_type = "text/html" ;; +let default_encoding = "utf8" ;; +let logfile = + Some (try Sys.getenv "UWOBO_LOG_FILE" with Not_found -> default_log_file) +;; +let logfile_perm = 0o640 ;; let port = try int_of_string (Sys.getenv port_env_var) @@ -231,8 +234,11 @@ let main () = (* (1) system logger *) let logger_outchan = match logfile with - | None -> stderr + | None -> + debug_print "Logging to standard error"; + stderr | Some f -> + debug_print (sprintf "Logging to file %s" f); open_out_gen [Open_wronly; Open_append; Open_creat] logfile_perm f in let syslogger = -- 2.39.2