[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [MirageOS-devel] test, quality, tcpip
Le mercredi, 13 mai 2015 Ã 10:58, Thomas Leonard a Ãcrit : > I'm undecided about this. It is annoying when you want to log > something and you have to thread a logger all though the code to do > it. However, there are some useful benefits to passing it: > > - You can run two largely independent applications in a single > unikernel, with separate logging for each. > > - You could run two IP stacks, and log each interface to its own file. > > - main.ml can choose the top-level names for each logger, and then > each module can create a child logger for sub-components it creates, > forming a tree. This makes it easy to see where a message is coming > from, which isn't always obvious if modules choose their own names. > > Having it on every function might be too much, but perhaps a functor > argument would do? Or perhaps have both options, Irmin-style. Note that this problem is solved by what I mentioned in my response about lwt_log without having to thread a function or having functors (and is similar to your class example). Basically something like: module Log : sig type logging = [ `Public | `Private ] type 'a t constraint 'a = [< logging] val create : unit -> [`Public] t val set_level : 'a t -> level -> unit val to_private : [`Public] t -> [`Private] t val msg : [`Public] t -> ('a, Format.formatter, unit, unit) Pervasives.format4 -> 'a end If you want a tree structure then `Log.create` could take another optional parent log in argument. Now in your components: module My_component : sig val log : [`Private] Log.t ... end = struct let log = Log.create () let log_msg = Log.msg log let log = public_log (* now simply use log_msg throughout your component code *) end This allows users of component (e.g. the mirage tool) to configure the logging of the component. Best, Daniel _______________________________________________ MirageOS-devel mailing list MirageOS-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |