diff --git a/src/os_comet.eliom b/src/os_comet.eliom index ba4c61f6..fe034207 100644 --- a/src/os_comet.eliom +++ b/src/os_comet.eliom @@ -86,8 +86,10 @@ let already_send_ref = let%client handle_error = ref (fun exn -> - Eliom_lib.Lwt_log.ign_info_f ~exn - "Exception received on Os_comet's monitor channel: "; + Logs.info (fun fmt -> + fmt + ("Exception received on Os_comet's monitor channel: " ^^ "@\n%s") + (Printexc.to_string exn)); restart_process (); Lwt.return_unit) @@ -96,7 +98,7 @@ let%client set_error_handler f = handle_error := f let%client handle_message = function | Error exn -> !handle_error exn | Ok Heartbeat -> - Eliom_lib.Lwt_log.ign_info_f "poum"; + Logs.info (fun fmt -> fmt "poum"); Lwt.return_unit | Ok Connection_changed -> Os_msg.msg ~level:`Err diff --git a/src/os_core_db.ml b/src/os_core_db.ml index ce840714..033743d1 100644 --- a/src/os_core_db.ml +++ b/src/os_core_db.ml @@ -21,7 +21,7 @@ open Lwt.Syntax open Resource_pooling -let section = Lwt_log.Section.make "os:db" +let section = Logs.Src.create "os:db" let ( >>= ) = Lwt.bind module Lwt_thread = struct @@ -120,15 +120,17 @@ let use_pool f = (fun () -> f db) (function | Lwt_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); let* () = Lwt_PGOCaml.close db in Lwt.fail e | (Unix.Unix_error _ | End_of_file) as e -> - Lwt_log.ign_error_f ~section ~exn:e "unix error"; + Logs.err ~src:section (fun fmt -> + fmt ("unix error" ^^ "@\n%s") (Printexc.to_string e)); let* () = Lwt_PGOCaml.close db in Lwt.fail e | Lwt.Canceled as e -> - Lwt_log.ign_error ~section "thread canceled"; + Logs.err ~src:section (fun fmt -> fmt "thread canceled"); let* () = PGOCaml.close db in Lwt.fail e | exc -> Lwt.reraise exc) @@ -154,7 +156,7 @@ let transaction_block db f = | Lwt_PGOCaml.PostgreSQL_Error _ -> (* If the rollback fails, for instance due to a timeout, it seems better to close the connection. *) - Lwt_log.ign_error ~section "rollback failed"; + Logs.err ~src:section (fun fmt -> fmt "rollback failed"); Lwt_PGOCaml.close db | exc -> Lwt.reraise exc) in diff --git a/src/os_msg.eliom b/src/os_msg.eliom index d14c3dca..3524fab0 100644 --- a/src/os_msg.eliom +++ b/src/os_msg.eliom @@ -50,7 +50,7 @@ let%shared if ~%onload then Eliom_client.lwt_onload () else Lwt.return_unit in let msgbox = msgbox () in - Eliom_lib.Lwt_log.ign_info_f "%s" ~%message; + Logs.info (fun fmt -> fmt "%s" ~%message); Dom.appendChild msgbox message_dom; let* () = Js_of_ocaml_lwt.Lwt_js.sleep ~%duration in Dom.removeChild msgbox message_dom; diff --git a/src/os_session.eliom b/src/os_session.eliom index 4edabba7..c966f1cc 100644 --- a/src/os_session.eliom +++ b/src/os_session.eliom @@ -20,7 +20,7 @@ open Lwt.Syntax -let log_section = Lwt_log.Section.make "os:session" +let log_section = Logs.Src.create "os:session" let user_indep_state_hierarchy = Eliom_common.create_scope_hierarchy "userindep" let user_indep_process_scope = `Client_process user_indep_state_hierarchy let user_indep_session_scope = `Session user_indep_state_hierarchy @@ -41,7 +41,8 @@ let mk_action_queue name = let* () = oldf arg in f arg) , fun arg -> - Lwt_log.ign_debug ~section:log_section ("handling actions: " ^ name); + Logs.debug ~src:log_section (fun fmt -> + fmt "%s" ("handling actions: " ^ name)); !r arg ) let on_connected_request, connected_request_action = diff --git a/src/os_user_view.eliom b/src/os_user_view.eliom index 959d7f46..c7e96ba5 100644 --- a/src/os_user_view.eliom +++ b/src/os_user_view.eliom @@ -323,7 +323,7 @@ let%shared Lwt.return_unit) (fun exn -> Os_msg.msg ~level:`Err "Error while uploading the picture"; - Eliom_lib.Lwt_log.ign_info_f "%s" ~exn "→ "; + Logs.info (fun fmt -> fmt "→ %s" (Printexc.to_string exn)); Lwt.return_unit)) : _)] :: a) diff --git a/template.distillery/.ocamlformat b/template.distillery/.ocamlformat index ee092cc1..78fc5bfb 100644 --- a/template.distillery/.ocamlformat +++ b/template.distillery/.ocamlformat @@ -1,3 +1,5 @@ +version=0.28.1 +parse-docstrings = false break-cases = fit break-collection-expressions = fit-or-vertical break-fun-decl = wrap diff --git a/template.distillery/PROJECT_NAME.eliom b/template.distillery/PROJECT_NAME.eliom index 7d9371a0..2fb620bb 100644 --- a/template.distillery/PROJECT_NAME.eliom +++ b/template.distillery/PROJECT_NAME.eliom @@ -53,24 +53,19 @@ let%server () = (* Print more debugging information when is in config file (DEBUG = yes in Makefile.options). Example of use: - let section = Lwt_log.Section.make "%%%MODULE_NAME%%%:sectionname" + let section = Logs.Src.create "%%%MODULE_NAME%%%:sectionname" ... - Lwt_log.ign_info ~section "This is an information"; - (or ign_debug, ign_warning, ign_error etc.) + Logs.info ~src:section (fun fmt -> "This is an information %i " 1); + (or Logs.debug, Logs.err etc.) *) let%server _ = if Eliom_config.get_debugmode () then ( - ignore +(* ignore [%client - ((* Eliom_config.debug_timings := true; *) - (* Lwt_log_core.add_rule "eliom:client*" Lwt_log_js.Debug; *) - (* Lwt_log_core.add_rule "os*" Lwt_log_js.Debug; *) - Lwt_log_core.add_rule "%%%MODULE_NAME%%%*" Lwt_log_js.Debug - (* Lwt_log_core.add_rule "*" Lwt_log_js.Debug *) - : unit)]; - (* Lwt_log_core.add_rule "*" Lwt_log.Debug *) - Lwt_log_core.add_rule "%%%MODULE_NAME%%%*" Lwt_log.Debug) + (Eliom_config.debug_timings := true + : unit)]; *) + Logs.set_level (Some Logs.Debug)) (* The modules below are all the modules that needs to be explicitely linked-in. *) diff --git a/template.distillery/PROJECT_NAME_mobile.eliom b/template.distillery/PROJECT_NAME_mobile.eliom index e22ecb86..e40f1cbe 100644 --- a/template.distillery/PROJECT_NAME_mobile.eliom +++ b/template.distillery/PROJECT_NAME_mobile.eliom @@ -148,5 +148,4 @@ let _ = debugger console, you can do so by uncommenting the following lines. *) (* let () = Eliom_config.debug_timings := true *) -(* let () = Lwt_log_core.add_rule "eliom:client*" Lwt_log_js.Debug *) -(* let () = Lwt_log_core.add_rule "os*" Lwt_log_js.Debug *) +(* let () = Logs.set_level (Some Logs.Debug) *)