Skip to content

Commit

Permalink
console
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Jan 17, 2025
1 parent 3ab3b05 commit 9d25750
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 54 deletions.
2 changes: 1 addition & 1 deletion examples/graph_viewer/viewer_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Format.eprintf "REDRAW %d %d %d %d@." x' y' w h;
let dx = pm.valid_rect.x - x0 in
let dy = pm.valid_rect.y - y0 in
(*
Firebug.console##log_6 (dx, pm.valid_rect.width, a.width,
Console.console##log_6 (dx, pm.valid_rect.width, a.width,
dy, pm.valid_rect.height, a.height);
*)
if
Expand Down
28 changes: 14 additions & 14 deletions examples/graph_viewer/viewer_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,18 @@ let start () =
if not !started then p##.style##.display := Js.string "inline";
Lwt.return ());
(*
Firebug.console##time(Js.string "loading");
Console.console##time(Js.string "loading");
*)
getfile "scene.json"
>>= fun s ->
(*
Firebug.console##timeEnd(Js.string "loading");
Firebug.console##time(Js.string "parsing");
Console.console##timeEnd(Js.string "loading");
Console.console##time(Js.string "parsing");
*)
let (x1, y1, x2, y2), bboxes, scene = of_json ~typ:[%json: scene] s in
(*
Firebug.console##timeEnd(Js.string "parsing");
Firebug.console##time(Js.string "init");
Console.console##timeEnd(Js.string "parsing");
Console.console##time(Js.string "init");
*)
started := true;
Dom.removeChild doc##.body p;
Expand Down Expand Up @@ -350,7 +350,7 @@ let start () =
let redraw_queued = ref false in
let update_view _force =
(*
Firebug.console##log_2(Js.string "update", Js.date##now());
Console.console##log_2(Js.string "update", Js.date##now());
*)
let a = allocation () in
let scale = get_scale () in
Expand Down Expand Up @@ -389,7 +389,7 @@ Firebug.console##log_2(Js.string "update", Js.date##now());
if not !redraw_queued then
ignore (redraw_queued := true;
(*
Firebug.console##log(Js.string "sleep");
Console.console##log(Js.string "sleep");
*)
Lwt_js.yield() >>= fun () ->
redraw_queued := false;
Expand Down Expand Up @@ -502,15 +502,15 @@ Firebug.console##log(Js.string "sleep");
(*
Html.addEventListener Html.document Html.Event.keydown
(Html.handler
(fun e -> Firebug.console##log(e##keyCode);
(fun e -> Console.console##log(e##keyCode);
Js._true))
Js._true;
*)
(*
Html.addEventListener Html.document Html.Event.keypress
(Html.handler
(fun e ->
Firebug.console##log(Js.string "press");
Console.console##log(Js.string "press");
match e##keyCode with
| 37 -> (* left *)
Js._false
Expand All @@ -521,7 +521,7 @@ Firebug.console##log(Js.string "sleep");
| 40 -> (* down *)
Js._false
| _ ->
Firebug.console##log(- 1- e##keyCode);
Console.console##log(- 1- e##keyCode);
Js._true))
Js._true;
*)
Expand Down Expand Up @@ -549,7 +549,7 @@ Firebug.console##log(Js.string "sleep");
Js._false
| _ ->
(*
Firebug.console##log_2(Js.string "keycode:", ev##keyCode);
Console.console##log_2(Js.string "keycode:", ev##keyCode);
*)
Js._true
in
Expand All @@ -564,12 +564,12 @@ Firebug.console##log(Js.string "sleep");
ignored_keycode := -1;
if e##.keyCode = k then Js._true else handle_key_event e);
(*
Firebug.console##time(Js.string "initial drawing");
Console.console##time(Js.string "initial drawing");
*)
update_view true;
(*
Firebug.console##timeEnd(Js.string "initial drawing");
Firebug.console##timeEnd(Js.string "init");
Console.console##timeEnd(Js.string "initial drawing");
Console.console##timeEnd(Js.string "init");
*)
Lwt.return ()

Expand Down
16 changes: 8 additions & 8 deletions examples/hyperbolic/hypertree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ let language =
(Html.window##.localStorage##getItem (Js.string "hyp_lang"))
default_language)

let _ = Firebug.console##log !language
let _ = Console.console##log !language

let set_language lang =
Html.window##.localStorage##setItem (Js.string "hyp_lang") lang;
Expand Down Expand Up @@ -643,7 +643,7 @@ type boxes =
let shadow = false

let draw canvas vertices edges nodes boxes =
Firebug.console##time (Js.string "draw");
Console.console##time (Js.string "draw");
let c = canvas##getContext Html._2d_ in
let ((rx, ry, dx, dy) as transf) = screen_transform canvas in
c##clearRect
Expand Down Expand Up @@ -795,8 +795,8 @@ let draw canvas vertices edges nodes boxes =
(Js.float (2. *. h))
| `Txt (_, None, _) | `None -> ()
done;
Firebug.console##timeEnd (Js.string "draw");
Firebug.console##log_2 !image_count !large_image_count
Console.console##timeEnd (Js.string "draw");
Console.console##log_2 !image_count !large_image_count

let tree_url = "tree.json"

Expand Down Expand Up @@ -1239,7 +1239,7 @@ let show_image all_messages image_info name small_image =
if !i >= 0
then (
let info = image_info.(!i) in
Firebug.console##log_2 name !i;
Console.console##log_2 name !i;
let d = Html.document in
let container = Html.createDiv d in
container##.style##.margin := Js.string "10px";
Expand Down Expand Up @@ -1582,7 +1582,7 @@ let start _ =
(redraw_funct :=
fun () ->
need_redraw := false;
Firebug.console##time (Js.string "transform");
Console.console##time (Js.string "transform");
(*
let transf = hyp_transf !tr' in
for i = 0 to Array.length vertices - 1 do
Expand All @@ -1596,7 +1596,7 @@ let start _ =
canvas##.width := w;
canvas##.height := h);
hyp_transf_vect !tr' vertices vertices';
Firebug.console##timeEnd (Js.string "transform");
Console.console##timeEnd (Js.string "transform");
draw canvas vertices' edges nodes boxes);
perform_redraw ();
Html.window##.onresize :=
Expand Down Expand Up @@ -1692,7 +1692,7 @@ debug_msg (Format.sprintf "Resize %d %d" w h);
handle_touch_events
canvas
(fun x0 y0 x1 y1 ->
Firebug.console##time (Js.string "transform");
Console.console##time (Js.string "transform");
let z0 = from_screen canvas x0 y0 in
let z1 = from_screen canvas x1 y1 in
(*
Expand Down
2 changes: 1 addition & 1 deletion examples/test_wheel/test_wheel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let () =
in
html##.onwheel :=
Dom.handler (fun (event : Dom_html.mousewheelEvent Js.t) ->
Firebug.console##debug event;
Console.console##debug event;
let deltaX = event##.deltaX in
let deltaY = event##.deltaY in
let deltaZ = event##.deltaZ in
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl/webgldemo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ open Js
let error f =
Printf.ksprintf
(fun s ->
Firebug.console##error (Js.string s);
Console.console##error (Js.string s);
failwith s)
f

let debug f = Printf.ksprintf (fun s -> Firebug.console##log (Js.string s)) f
let debug f = Printf.ksprintf (fun s -> Console.console##log (Js.string s)) f

let alert f =
Printf.ksprintf
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/js_of_ocaml/firebug.mli → lib/js_of_ocaml/console.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

(** Firebug API (debugging console).
(** Console API (debugging console).
The Firebug console API
The console API
*)

open Js
Expand Down
4 changes: 2 additions & 2 deletions lib/js_of_ocaml/geolocation.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
let f_success pos =
let coords = pos##.coords in
let latitude = coords##.latitude in
Firebug.console##debug latitude ;
Console.console##debug latitude ;
in
let f_error err =
let code = err##.code in
let msg = err##.message in
if code = err##._TIMEOUT then Firebug.console##debug(msg)
if code = err##._TIMEOUT then Console.console##debug(msg)
in
geo##getCurrentPosition (Js.wrap_callback f_success) (Js.wrap_callback f_error) options
]}
Expand Down
6 changes: 3 additions & 3 deletions lib/js_of_ocaml/intl.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
open Js ;;
let fc v = Firebug.console##debug v in
let fc v = Console.console##debug v in
let jas a = array(Array.map (fun v -> string v) a) in
Expand Down Expand Up @@ -410,10 +410,10 @@ if (Intl.is_supported()) then (
) ;
with
| Error err -> Firebug.console##debug (
| Error err -> Console.console##debug (
string (string_of_error err)) ;
) else (
Firebug.console##debug (string "Intl is not supported!") ;
Console.console##debug (string "Intl is not supported!") ;
)
]}
Expand Down
4 changes: 3 additions & 1 deletion lib/js_of_ocaml/js_of_ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
*)

module CSS = CSS
module Console = Console
module Dom = Dom
module Dom_events = Dom_events
module Dom_html = Dom_html
module Dom_svg = Dom_svg
module Effect_js = Effect_js
module EventSource = EventSource
module File = File
module Firebug = Firebug
module Firebug = Console
[@@ocaml.deprecated "[since 6.0] Use Js_of_ocaml.Console instead."]
module Form = Form
module Geolocation = Geolocation
module IntersectionObserver = IntersectionObserver
Expand Down
4 changes: 2 additions & 2 deletions lib/js_of_ocaml/mutationObserver.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
in
let node = (target :> Dom.node Js.t) in
let f records observer =
Firebug.console##debug records ;
Firebug.console##debug observer
Console.console##debug records ;
Console.console##debug observer
in
MutationObserver.observe ~node ~f
~attributes:true ~child_list:true ~character_data:true
Expand Down
4 changes: 2 additions & 2 deletions lib/js_of_ocaml/performanceObserver.mli
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
let entry_types = [ "measure" ] in
let f entries observer =
let entries = entries##getEntries in
Firebug.console##debug entries ;
Firebug.console##debug observer
Console.console##debug entries ;
Console.console##debug observer
in
PerformanceObserver.observe ~entry_types ~f
()
Expand Down
4 changes: 2 additions & 2 deletions lib/js_of_ocaml/resizeObserver.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
in
let node = (target :> Dom.node Js.t) in
let f entries observer =
Firebug.console##debug entries;
Firebug.console##debug observer
Console.console##debug entries;
Console.console##debug observer
in
ResizeObserver.observe ~node ~f
~box:(Js.string "content-box")
Expand Down
16 changes: 8 additions & 8 deletions lib/lwt/log/lwt_log_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ let console =
(Printf.sprintf "[%s] %s" (Section.name section) (String.concat "\n" logs))
in
(match level, Lwt.get js_val with
| Debug, None -> Firebug.console##debug str
| Debug, Some v -> Firebug.console##debug_2 str v
| Info, None | Notice, None -> Firebug.console##info str
| Info, Some v | Notice, Some v -> Firebug.console##info_2 str v
| Warning, None -> Firebug.console##warn str
| Warning, Some v -> Firebug.console##warn_2 str v
| Error, None | Fatal, None -> Firebug.console##error str
| Error, Some v | Fatal, Some v -> Firebug.console##error_2 str v);
| Debug, None -> Console.console##debug str
| Debug, Some v -> Console.console##debug_2 str v
| Info, None | Notice, None -> Console.console##info str
| Info, Some v | Notice, Some v -> Console.console##info_2 str v
| Warning, None -> Console.console##warn str
| Warning, Some v -> Console.console##warn_2 str v
| Error, None | Fatal, None -> Console.console##error str
| Error, Some v | Fatal, Some v -> Console.console##error_2 str v);
Lwt.return_unit)

let log ?inspect ?exn ?section ?location ?logger ~level message =
Expand Down
2 changes: 1 addition & 1 deletion lib/lwt/lwt_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let wakeup = function

let () = Lwt.register_pause_notifier wakeup

let prerr_string s = Firebug.console##log (Js.string s)
let prerr_string s = Console.console##log (Js.string s)

let _ =
Lwt.async_exception_hook :=
Expand Down
4 changes: 2 additions & 2 deletions lib/lwt/lwt_js_events.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let with_error_log f x =
Lwt.catch
(fun () -> f x)
(fun e ->
Firebug.console##log (Js.string (Printexc.to_string e));
Console.console##log (Js.string (Printexc.to_string e));
Lwt.return ())

let seq_loop evh ?(cancel_handler = false) ?use_capture ?passive target handler =
Expand Down Expand Up @@ -330,7 +330,7 @@ let mousewheel ?use_capture ?passive target =
?passive:(opt_map Js.bool passive)
target
(fun (ev : #Dom_html.event Js.t) ~dx ~dy ->
Firebug.console##log ev;
Console.console##log ev;
cancel ();
Lwt.wakeup w (ev, (dx, dy));
Js.bool true)
Expand Down
2 changes: 1 addition & 1 deletion lib/lwt/lwt_jsonp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let raw_call name uri error_cb user_cb =
if !executed
then Lwt.return_unit
else (
Firebug.console##warn
Console.console##warn
(Js.string "Jsonp: script loaded but callback not executed");
finalize ();
error_cb x;
Expand Down
4 changes: 2 additions & 2 deletions toplevel/examples/lwt_toplevel/toplevel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ let run _ =
match exc with
| Js_error.Exn e ->
let e = Js_error.to_error e in
Firebug.console##log e##.stack
Console.console##log e##.stack
| _ -> ());
Lwt.async (fun () ->
resize ~container ~textbox ()
Expand Down Expand Up @@ -477,7 +477,7 @@ let run _ =
with
| Not_found -> ()
| exc ->
Firebug.console##log_3
Console.console##log_3
(Js.string "exception")
(Js.string (Printexc.to_string exc))
exc
Expand Down

0 comments on commit 9d25750

Please sign in to comment.