Skip to content

Commit 0bb1a6a

Browse files
authored
Merge pull request #822 from Julow/lwt_log_to_logs
Migrate from Lwt_log to Logs
2 parents 4377b1d + 471b0f0 commit 0bb1a6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+328
-284
lines changed

dune-project

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ The client-side code is compiled to JS using Ocsigen Js_of_ocaml or to Wasm usin
3333
(js_of_ocaml-ppx (>= 6.0))
3434
(js_of_ocaml-ppx_deriving_json (>= 6.0))
3535
(js_of_ocaml-tyxml (>= 6.0))
36-
lwt_log
36+
logs
3737
(tyxml (and (>= 4.6) (< 4.7)))
3838
(ocsigenserver (and (>= 6.0) (< 7.0)))
39-
lwt_log
4039
(ipaddr (>= 2.1))
4140
(reactiveData (>= 0.2.1))
4241
base-bytes

eliom.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ depends: [
2929
"js_of_ocaml-ppx" {>= "6.0"}
3030
"js_of_ocaml-ppx_deriving_json" {>= "6.0"}
3131
"js_of_ocaml-tyxml" {>= "6.0"}
32-
"lwt_log"
32+
"logs"
3333
"tyxml" {>= "4.6" & < "4.7"}
3434
"ocsigenserver" {>= "6.0" & < "7.0"}
3535
"ipaddr" {>= "2.1"}

src/lib/client/dune

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
js_of_ocaml
2323
js_of_ocaml-tyxml
2424
js_of_ocaml-lwt
25-
js_of_ocaml-lwt.logger
2625
lwt_react
2726
ocsigenserver.baselib.base
27+
logs
28+
logs.browser
2829
cohttp
2930
tyxml
3031
reactiveData)

src/lib/client/eliommod_dom.ml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ open Lwt.Syntax
2222
open Js_of_ocaml
2323
open Eliom_lib
2424

25-
let section = Lwt_log.Section.make "eliom:dom"
25+
let section = Logs.Src.create "eliom:dom"
2626

2727
let iter_nodeList nodeList f =
2828
for i = 0 to nodeList##.length - 1 do
@@ -420,14 +420,20 @@ let html_document (src : Dom.element Dom.document Js.t) registered_process_node
420420
| Some e -> (
421421
try Dom_html.document##(adoptNode (e :> Dom.element Js.t))
422422
with exn -> (
423-
Lwt_log.ign_debug ~section ~exn "can't adopt node, import instead";
423+
Logs.debug ~src:section (fun fmt ->
424+
fmt
425+
("can't adopt node, import instead" ^^ "@\n%s")
426+
(Printexc.to_string exn));
424427
try Dom_html.document##(importNode (e :> Dom.element Js.t) Js._true)
425428
with exn ->
426-
Lwt_log.ign_debug ~section ~exn "can't import node, copy instead";
429+
Logs.debug ~src:section (fun fmt ->
430+
fmt
431+
("can't import node, copy instead" ^^ "@\n%s")
432+
(Printexc.to_string exn));
427433
copy_element content registered_process_node))
428434
| None ->
429-
Lwt_log.ign_debug ~section
430-
"can't adopt node, document not parsed as html. copy instead";
435+
Logs.debug ~src:section (fun fmt ->
436+
fmt "can't adopt node, document not parsed as html. copy instead");
431437
copy_element content registered_process_node
432438

433439
(** CSS preloading. *)
@@ -627,7 +633,10 @@ and rewrite_css_import ?(charset = "") ~max ~prefix ~media css pos =
627633
with
628634
| Incorrect_url -> Lwt.return ([], rewrite_css_url ~prefix css pos)
629635
| exn ->
630-
Lwt_log.ign_info ~section ~exn "Error while importing css";
636+
Logs.info ~src:section (fun fmt ->
637+
fmt
638+
("Error while importing css" ^^ "@\n%s")
639+
(Printexc.to_string exn));
631640
Lwt.return ([], rewrite_css_url ~prefix css pos))
632641

633642
let max_preload_depth = ref 4
@@ -666,9 +675,11 @@ let preload_css (doc : Dom_html.element Js.t) =
666675
(fun (e, css) ->
667676
try Dom.replaceChild (get_head doc) css e
668677
with _ ->
669-
(* Node was a unique node that has been removed...
678+
Logs.info
679+
~src:
680+
(* Node was a unique node that has been removed...
670681
in a perfect settings we won't have parsed it... *)
671-
Lwt_log.ign_info ~section "Unique CSS skipped...")
682+
section (fun fmt -> fmt "Unique CSS skipped..."))
672683
css;
673684
if !Eliom_config.debug_timings
674685
then Console.console##(timeEnd (Js.string "preload_css (fetch+rewrite)"));

src/lib/client/eliommod_dom.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ val onhashchange : (Js.js_string Js.t -> unit) -> unit
101101

102102
val touch_base : unit -> unit
103103
val add_formdata_hack_onclick_handler : unit -> unit
104-
val section : Lwt_log_core.section
104+
val section : Logs.src

src/lib/eliom_bus.client.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open Lwt.Syntax
2323

2424
open Eliom_lib
2525

26-
let section = Lwt_log.Section.make "eliom:bus"
26+
let section = Logs.Src.create "eliom:bus"
2727

2828
module Ecb = Eliom_comet_base
2929

src/lib/eliom_bus.client.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ val set_time_before_flush : ('a, 'b) t -> float -> unit
6464
(**/**)
6565

6666
val force_link : unit
67-
val section : Lwt_log_core.section
67+
val section : Logs.src

0 commit comments

Comments
 (0)