From 70bd2cfbef0c46b4ca4095c3469b07aa154be6ba Mon Sep 17 00:00:00 2001 From: Jan Rochel Date: Thu, 11 Jul 2019 13:56:52 +0200 Subject: [PATCH 1/4] verbose flag only affects log levels of sections "ocsigenserver:*" --- src/baselib/ocsigen_config.ml.in | 6 +++--- src/extensions/ocsipersist-dbm/ocsipersist.ml | 2 +- src/extensions/ocsipersist-pgsql/ocsipersist.ml | 2 +- src/extensions/ocsipersist-sqlite/ocsipersist.ml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/baselib/ocsigen_config.ml.in b/src/baselib/ocsigen_config.ml.in index 94569a52d..9114c9a38 100644 --- a/src/baselib/ocsigen_config.ml.in +++ b/src/baselib/ocsigen_config.ml.in @@ -83,18 +83,18 @@ let set_mimefile s = mimefile := s let () = Lwt_log.add_rule "*" Lwt_log.Warning (* without --verbose *) let set_verbose () = verbose := true; - Lwt_log.add_rule "*" Lwt_log.Notice + Lwt_log.add_rule "ocsigen:*" Lwt_log.Notice let set_silent () = silent := true let set_daemon () = set_silent (); daemon := true let set_veryverbose () = verbose := true; veryverbose := true; - Lwt_log.add_rule "*" Lwt_log.Info + Lwt_log.add_rule "ocsigen:*" Lwt_log.Info let set_debug () = verbose := true; veryverbose := true; debug := true; - Lwt_log.add_rule "*" Lwt_log.Debug + Lwt_log.add_rule "ocsigen:*" Lwt_log.Debug let set_minthreads i = minthreads := i let set_maxthreads i = maxthreads := i diff --git a/src/extensions/ocsipersist-dbm/ocsipersist.ml b/src/extensions/ocsipersist-dbm/ocsipersist.ml index 12225a73f..28394d54f 100644 --- a/src/extensions/ocsipersist-dbm/ocsipersist.ml +++ b/src/extensions/ocsipersist-dbm/ocsipersist.ml @@ -25,7 +25,7 @@ open Ocsidbmtypes open Lwt -let section = Lwt_log.Section.make "ocsipersist:dbm" +let section = Lwt_log.Section.make "ocsigen:ocsipersist:dbm" (** Data are divided into stores. Create one store for your project, where you will save all your data. *) diff --git a/src/extensions/ocsipersist-pgsql/ocsipersist.ml b/src/extensions/ocsipersist-pgsql/ocsipersist.ml index 2bab268c6..f09afb820 100644 --- a/src/extensions/ocsipersist-pgsql/ocsipersist.ml +++ b/src/extensions/ocsipersist-pgsql/ocsipersist.ml @@ -1,6 +1,6 @@ (** PostgreSQL (>= 9.5) backend for Ocsipersist. *) -let section = Lwt_log.Section.make "ocsipersist:pgsql" +let section = Lwt_log.Section.make "ocsigen:ocsipersist:pgsql" module Lwt_thread = struct include Lwt diff --git a/src/extensions/ocsipersist-sqlite/ocsipersist.ml b/src/extensions/ocsipersist-sqlite/ocsipersist.ml index 42485f067..3b2443d48 100644 --- a/src/extensions/ocsipersist-sqlite/ocsipersist.ml +++ b/src/extensions/ocsipersist-sqlite/ocsipersist.ml @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let section = Lwt_log.Section.make "ocsipersist:sqlite" +let section = Lwt_log.Section.make "ocsigen:ocsipersist:sqlite" (** Module Ocsipersist: persistent data *) From 81b01e9e596d837c2d6b1b1953fe1297ca8f8c52 Mon Sep 17 00:00:00 2001 From: Jan Rochel Date: Thu, 11 Jul 2019 15:49:09 +0200 Subject: [PATCH 2/4] always log to console (stderr) not only if -v is given The right way to control the verbosity with regards to logging is to change the log level. --- src/baselib/ocsigen_messages.ml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/baselib/ocsigen_messages.ml b/src/baselib/ocsigen_messages.ml index 37b10169c..cb4a6c629 100644 --- a/src/baselib/ocsigen_messages.ml +++ b/src/baselib/ocsigen_messages.ml @@ -81,14 +81,7 @@ let open_files ?(user = Ocsigen_config.get_user ()) ?(group = Ocsigen_config.get | _ -> Lwt_log.null); Lwt_log.dispatch (fun sect lev -> - let show = - match lev with - | Lwt_log.Error | Lwt_log.Fatal -> - not (Ocsigen_config.get_silent ()) - | _ -> - Ocsigen_config.get_verbose () - in - if show then stderr else Lwt_log.null)]; + if Ocsigen_config.get_silent () then Lwt_log.null else stderr)]; let gid = match group with | None -> Unix.getgid () From 16942069f99779bc0a3fc216a75721a3c5577b5f Mon Sep 17 00:00:00 2001 From: Jan Rochel Date: Thu, 11 Jul 2019 17:02:34 +0200 Subject: [PATCH 3/4] access/warning/error.log: allow for symlinks to /dev/null --- src/baselib/ocsigen_messages.ml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/baselib/ocsigen_messages.ml b/src/baselib/ocsigen_messages.ml index cb4a6c629..f2e3a3899 100644 --- a/src/baselib/ocsigen_messages.ml +++ b/src/baselib/ocsigen_messages.ml @@ -96,9 +96,16 @@ let open_files ?(user = Ocsigen_config.get_user ()) ?(group = Ocsigen_config.get (Unix.getpwnam user).Unix.pw_uid with Not_found as e -> ignore (Lwt_log.error "Error: Wrong user"); raise e) in - Lwt_unix.chown (full_path access_file) uid gid >>= fun () -> - Lwt_unix.chown (full_path warning_file) uid gid >>= fun () -> - Lwt_unix.chown (full_path error_file) uid gid + Lwt.catch + (fun () -> + Lwt_unix.chown (full_path access_file) uid gid >>= fun () -> + Lwt_unix.chown (full_path warning_file) uid gid >>= fun () -> + Lwt_unix.chown (full_path error_file) uid gid) + (fun e -> match e with + | Unix.Unix_error (Unix.EPERM, _, _) -> + (* to allow for symlinks to /dev/null *) + Lwt.return_unit + | _ -> Lwt.fail e) (****) From 2c5bd2554c2ab21e2089e2f34f15e9ca2f7193fa Mon Sep 17 00:00:00 2001 From: Jan Rochel Date: Thu, 11 Jul 2019 16:07:04 +0200 Subject: [PATCH 4/4] release 2.13.0 --- opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opam b/opam index c62a91004..6f968d62f 100644 --- a/opam +++ b/opam @@ -1,6 +1,6 @@ opam-version: "2.0" name: "ocsigenserver" -version: "2.12.0" +version: "2.13.0" maintainer: "dev@ocsigen.org" synopsis: "A full-featured and extensible Web server." description: "Ocsigen Server implements most features of the HTTP protocol, and has a very powerful extension mechanism that makes it very easy to plug your own OCaml modules for generating pages. Many extensions are already implemented, like a reverse proxy, content compression, access control, authentication, etc."