Consistent log level with `Async.Std.Log.Global` across different modules

15 views
Skip to first unread message

Dominik Gabi

unread,
Jan 17, 2017, 9:40:27 PM1/17/17
to ocaml-core
Hi All,
potential dummy question: I'm playing with async and I have several modules from which I want to log. So in module `A` I have something along the lines of 

  open Async.Std
  module Log = Log.Global
  ...
  Log.set_level (if verbose then `Debug else `Info);
  Log.debug "blah";

and if I pass a `-verbose` option to my binary I get all the debug output. However, if I call `Log.debug` from module `B` (after the above code has been executed) the output is swallowed unless I call `set_level` again. Am I missing something here? Do I have to pass my `verbose` flag to every module in my program and re-initialize the logging module?

Thanks,
Dominik

David House

unread,
Jan 18, 2017, 7:01:46 AM1/18/17
to ocaml-core
It should work. It's hard to know why it's not without looking at your code in more detail. Although I will mention that most of the time, one does this kind of logging setup in the "main" function of your program, rather than at the module top-level as it looks like you are doing here.

--
You received this message because you are subscribed to the Google Groups "ocaml-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocaml-core+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages