[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MirageOS-devel] Thoughts on logging

Logging came up in today's call again, and it was suggested that
perhaps we could get started by adding a LOG signature to
mirage-types. I've just added one to mirage-qubes, and dsj55 recently
added one to ocaml-9p. Would be good to have a common one. Probably
base to base it on the (currently unreleased) Logs library.

I tried using the Logs library in ocaml-9p (PR:
https://github.com/mirage/ocaml-9p/pull/18). Some results from that:

- Although it's convenient for existing code to make its own loggers
(and we should support this), for new code we might prefer to take a
LOG module as a functor argument (e.g. as in

- To help with that, it would be useful if the LOG signature included
a way to make child loggers. That way I can pass a single [ocaml9p]
LOG to ocaml-9p and it can create child loggers (e.g. [ocaml9p.wire])
if desired.

- I'm not sure about the callback-based syntax. e.g.

-    Log.debug "Negotiated maximum message size: %ld bytes" msize;
+    Log.debug "Negotiated maximum message size: %ld bytes" (fun msg
-> msg msize);

It may be faster, but it's also uglier. Possibly we should use a
syntax extension instead, which would expand the original form to:

  if Log.want_debug () then Log.debug "Negotiated maximum message
size: %ld bytes" msize;

In that case, the LOG signature should provide the original API and we
can add the "want_*" functions later.

However, there were several places where the old code was calculating
values to use in the following log statement, and the new style
encouraged moving these into the callback, which is more efficient).

- The Log.Tag.t type is abstract, which might make it hard to provide
compatible implementation from another library. Possibly the mirage
signature could leave tags as abstract to remain compatible.


Dr Thomas Leonard        http://roscidus.com/blog/
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

MirageOS-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.