Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/os_comet.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/os_core_db.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/os_msg.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/os_session.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/os_user_view.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions template.distillery/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version=0.28.1
parse-docstrings = false
break-cases = fit
break-collection-expressions = fit-or-vertical
break-fun-decl = wrap
Expand Down
19 changes: 7 additions & 12 deletions template.distillery/PROJECT_NAME.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,19 @@ let%server () =
(* Print more debugging information when <debugmode/> 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. *)
Expand Down
3 changes: 1 addition & 2 deletions template.distillery/PROJECT_NAME_mobile.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -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) *)
Loading