diff --git a/dune-project b/dune-project index 5559fd9..5ba7cb6 100644 --- a/dune-project +++ b/dune-project @@ -27,7 +27,7 @@ (depends (ocsipersist (= :version)) (lwt (>= 4.2.0)) - lwt_log + logs dbm)) (package @@ -54,7 +54,7 @@ (ocaml (>= 4.08)) (ocsipersist (= :version)) (lwt (>= 4.2.0)) - lwt_log + logs pgocaml)) (package @@ -72,7 +72,7 @@ (description "This library provides a SQLite backend for the unified key/value storage frontend as defined in the ocsipersist package.") (depends (lwt (>= 4.2.0)) - lwt_log + logs ocsipersist sqlite3)) diff --git a/ocsipersist-dbm.opam b/ocsipersist-dbm.opam index 4830e34..a322fc9 100644 --- a/ocsipersist-dbm.opam +++ b/ocsipersist-dbm.opam @@ -12,7 +12,7 @@ depends: [ "dune" {>= "2.8"} "ocsipersist" {= version} "lwt" {>= "4.2.0"} - "lwt_log" + "logs" "dbm" "odoc" {with-doc} ] diff --git a/ocsipersist-pgsql.opam b/ocsipersist-pgsql.opam index b5131d6..046d620 100644 --- a/ocsipersist-pgsql.opam +++ b/ocsipersist-pgsql.opam @@ -13,7 +13,7 @@ depends: [ "ocaml" {>= "4.08"} "ocsipersist" {= version} "lwt" {>= "4.2.0"} - "lwt_log" + "logs" "pgocaml" "odoc" {with-doc} ] diff --git a/ocsipersist-sqlite.opam b/ocsipersist-sqlite.opam index 6beaceb..3fad525 100644 --- a/ocsipersist-sqlite.opam +++ b/ocsipersist-sqlite.opam @@ -11,7 +11,7 @@ bug-reports: "https://github.com/ocsigen/ocsipersist/issues" depends: [ "dune" {>= "2.8"} "lwt" {>= "4.2.0"} - "lwt_log" + "logs" "ocsipersist" "sqlite3" "odoc" {with-doc} diff --git a/src/dbm/dune b/src/dbm/dune index 4129756..e1b0e6a 100644 --- a/src/dbm/dune +++ b/src/dbm/dune @@ -18,7 +18,7 @@ ocsipersist_settings) (libraries dbm - lwt_log + logs ocsipersist_dbmtypes ocsipersist_lib ocsipersist_dbm_settings)) diff --git a/src/dbm/ocsipersist.ml b/src/dbm/ocsipersist.ml index c03ecb7..2f00aef 100644 --- a/src/dbm/ocsipersist.ml +++ b/src/dbm/ocsipersist.ml @@ -5,7 +5,7 @@ open Lwt.Infix module type TABLE = Ocsipersist_lib.Sigs.TABLE -let section = Lwt_log.Section.make "ocsigen:ocsipersist:dbm" +let section = Logs.Src.create "ocsigen:ocsipersist:dbm" exception Ocsipersist_error @@ -25,9 +25,9 @@ module Db = struct Lwt_unix.connect socket (Unix.ADDR_UNIX sname) >>= fun () -> Lwt.return socket) (fun _ -> - Lwt_log.ign_warning_f ~section - "Launching a new Ocsidbm process: %s on directory %s." - !Config.ocsidbm !Config.directory; + Logs.warn ~src:section (fun fmt -> + fmt "Launching a new Ocsidbm process: %s on directory %s." + !Config.ocsidbm !Config.directory); let param = [|!Config.ocsidbm; !Config.directory|] in let child () = let log = @@ -63,14 +63,15 @@ module Db = struct (fun e -> if i = 0 then ( - Lwt_log.ign_error_f ~section - "Cannot connect to Ocsidbm. Will continue without persistent session support. Error message is: %s .Have a look at the logs to see if there is an error message from the Ocsidbm process." - (match e with - | Unix.Unix_error (a, b, c) -> - Printf.sprintf "%a in %s(%s)" - (fun () -> Unix.error_message) - a b c - | _ -> Printexc.to_string e); + Logs.err ~src:section (fun fmt -> + fmt + "Cannot connect to Ocsidbm. Will continue without persistent session support. Error message is: %s .Have a look at the logs to see if there is an error message from the Ocsidbm process." + (match e with + | Unix.Unix_error (a, b, c) -> + Printf.sprintf "%a in %s(%s)" + (fun () -> Unix.error_message) + a b c + | _ -> Printexc.to_string e)); Lwt.fail e) else Lwt_unix.sleep 2.1 >>= fun () -> get_indescr (i - 1)) @@ -327,8 +328,9 @@ type 'value table = 'value Polymorphic.table let init () = if !Ocsipersist_settings.delay_loading then - Lwt_log.ign_warning ~section "Asynchronuous initialization (may fail later)" - else Lwt_log.ign_warning ~section "Initializing ..."; + Logs.warn ~src:section (fun fmt -> + fmt "Asynchronuous initialization (may fail later)") + else Logs.warn ~src:section (fun fmt -> fmt "Initializing ..."); let indescr = Db.get_indescr 2 in if !Ocsipersist_settings.delay_loading then ( @@ -341,4 +343,4 @@ let init () = Ocsipersist_settings.inch := Lwt.return (Lwt_io.of_fd ~mode:Lwt_io.input r); Ocsipersist_settings.outch := Lwt.return (Lwt_io.of_fd ~mode:Lwt_io.output r); - Lwt_log.ign_warning ~section "...Initialization complete" + Logs.warn ~src:section (fun fmt -> fmt "...Initialization complete") diff --git a/src/pgsql/dune b/src/pgsql/dune index a795067..85eebec 100644 --- a/src/pgsql/dune +++ b/src/pgsql/dune @@ -3,7 +3,7 @@ (public_name ocsipersist-pgsql) (implements ocsipersist) (modules :standard \ ocsipersist_config ocsipersist_settings) - (libraries pgocaml lwt_log ocsipersist_lib ocsipersist_pgsql_settings)) + (libraries pgocaml lwt.unix logs ocsipersist_lib ocsipersist_pgsql_settings)) ; Configuration functions (part of ocsipersist-pgsql package): diff --git a/src/pgsql/ocsipersist.ml b/src/pgsql/ocsipersist.ml index cc4f178..927a63e 100644 --- a/src/pgsql/ocsipersist.ml +++ b/src/pgsql/ocsipersist.ml @@ -2,7 +2,7 @@ module type TABLE = Ocsipersist_lib.Sigs.TABLE -let section = Lwt_log.Section.make "ocsigen:ocsipersist:pgsql" +let section = Logs.Src.create "ocsigen:ocsipersist:pgsql" module Lwt_thread = struct include Lwt @@ -55,10 +55,11 @@ let use_pool f = (fun () -> f db) (function | PGOCaml.Error msg as e -> - Lwt_log.ign_error_f ~section "postgresql protocol error: %s" msg; + Logs.err ~src:section (fun fmt -> + fmt "postgresql protocol error: %s" msg); PGOCaml.close db >>= fun () -> Lwt.fail e | Lwt.Canceled as e -> - Lwt_log.ign_error ~section "thread canceled"; + Logs.err ~src:section (fun fmt -> fmt "thread canceled"); PGOCaml.close db >>= fun () -> Lwt.fail e | e -> Lwt.fail e) diff --git a/src/pgsql/ocsipersist_config.ml b/src/pgsql/ocsipersist_config.ml index 7563e6a..034dc2a 100644 --- a/src/pgsql/ocsipersist_config.ml +++ b/src/pgsql/ocsipersist_config.ml @@ -1,5 +1,7 @@ -let section = Lwt_log.Section.make "ocsigen:ocsipersist:pgsql:config" -let _ = Lwt_log.ign_info ~section "Init for Ocsigen Server config file" +let section = Logs.Src.create "ocsigen:ocsipersist:pgsql:config" + +let _ = + Logs.info ~src:section (fun fmt -> fmt "Init for Ocsigen Server config file") let parse_global_config = function | [] -> () diff --git a/src/sqlite/dune b/src/sqlite/dune index 4ef220a..b24805d 100644 --- a/src/sqlite/dune +++ b/src/sqlite/dune @@ -3,7 +3,12 @@ (public_name ocsipersist-sqlite) (implements ocsipersist) (modules ocsipersist) - (libraries sqlite3 lwt_log ocsipersist_lib ocsipersist_sqlite_settings)) + (libraries + sqlite3 + lwt.unix + logs + ocsipersist_lib + ocsipersist_sqlite_settings)) ; Configuration functions (part of ocsipersist-sqlite package): diff --git a/src/sqlite/ocsipersist.ml b/src/sqlite/ocsipersist.ml index 5d1040a..bfedb1b 100644 --- a/src/sqlite/ocsipersist.ml +++ b/src/sqlite/ocsipersist.ml @@ -1,6 +1,6 @@ module type TABLE = Ocsipersist_lib.Sigs.TABLE -let section = Lwt_log.Section.make "ocsigen:ocsipersist:sqlite" +let section = Logs.Src.create "ocsigen:ocsipersist:sqlite" open Lwt.Infix open Sqlite3 @@ -24,7 +24,7 @@ module Aux = struct let close_safely db = if not (db_close db) - then Lwt_log.ign_error ~section "Couldn't close database" + then Logs.err ~src:section (fun fmt -> fmt "Couldn't close database") let m = Mutex.create ()