diff --git a/riot/lib/logger/logger.ml b/riot/lib/logger/logger.ml index eb26c057..245b7ebf 100644 --- a/riot/lib/logger/logger.ml +++ b/riot/lib/logger/logger.ml @@ -3,6 +3,7 @@ module Log = Riot_runtime.Log open Global type opts = { print_source : bool; print_time : bool; color_output : bool } +type config = { opts : opts; started_by : Riot_runtime.Core.Pid.t } type ('a, 'b) logger_format = (('a, Format.formatter, unit, 'b) format4 -> 'a) -> 'b diff --git a/riot/lib/logger_app.ml b/riot/lib/logger_app.ml index 10b324f7..85486dbb 100644 --- a/riot/lib/logger_app.ml +++ b/riot/lib/logger_app.ml @@ -5,6 +5,8 @@ open Logger.Make (struct let namespace = [ "riot"; "logger" ] end) +type Message.t += Logger_ready + module Formatter = struct type Message.t += Log of log @@ -47,7 +49,8 @@ module Formatter = struct let pid = spawn_link (fun () -> Process.flag (Priority High); - formatter_loop config) + send config.started_by Logger_ready; + formatter_loop config.opts) in set_on_log (fun log -> send pid (Log log)); Ok pid @@ -59,5 +62,12 @@ let default_opts = { print_time = true; print_source = false; color_output = true } let start () = - let child_specs = [ Formatter.child_spec default_opts ] in - Supervisor.start_link ~child_specs () + let this = self () in + let config = { opts = default_opts; started_by = this } in + let child_specs = [ Formatter.child_spec config ] in + let result = Supervisor.start_link ~child_specs () in + let `ready = + let selector msg = if msg = Logger_ready then `select `ready else `skip in + receive ~selector () + in + result