Skip to content

Commit

Permalink
fix: user same logger throughout net module
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Dec 24, 2023
1 parent a42f99e commit bf5aee8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions riot/lib/io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ module Reader = struct

let read : type src. src t -> buf:Buffer.t -> (int, [> `Closed ]) result =
fun (Reader ((module R), src)) ~buf ->
Logger.trace (fun f -> f " IO.Reader.read");
match R.read src ~buf with
| Ok len -> Ok len
| Error `Eof -> Ok 0
Expand Down
5 changes: 1 addition & 4 deletions riot/lib/net.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ end
module Socket = struct
include Runtime.Net.Socket

module Logger = Logger.Make (struct
let namespace = [ "riot"; "net"; "socket" ]
end)

type listen_opts = {
reuse_addr : bool;
reuse_port : bool;
Expand Down Expand Up @@ -108,6 +104,7 @@ module Socket = struct
let controlling_process _socket ~new_owner:_ = Ok ()

let rec receive ?(timeout = Infinity) ~buf socket =
Logger.trace (fun f -> f "Riot.Net.Socket.receive");
match Low_level.readv socket [| Io.Buffer.as_cstruct buf |] with
| exception Fd.(Already_closed _) -> Error `Closed
| `Abort reason -> Error (`Unix_error reason)
Expand Down
2 changes: 1 addition & 1 deletion riot/riot.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let shutdown () =
Scheduler.Pool.shutdown pool

let run ?(rnd = Random.State.make_self_init ())
?(workers = max 0 (Stdlib.Domain.recommended_domain_count () - 1)) main =
?(workers = Int.max 0 (Stdlib.Domain.recommended_domain_count () - 1)) main =
Log.debug (fun f -> f "Initializing Riot runtime...");
Printexc.record_backtrace true;
Pid.reset ();
Expand Down
2 changes: 1 addition & 1 deletion test/io_reader_large_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let test_with_buffer capacity =
let () =
Riot.run @@ fun () ->
let _ = Logger.start () |> Result.get_ok in
Logger.set_log_level (Some Trace);
Logger.set_log_level (Some Info);
(* smallest buffer that will work than the target and the source*)
test_with_buffer 4;
(* smallest than the target and the source*)
Expand Down

0 comments on commit bf5aee8

Please sign in to comment.