From: Ian Jackson Subject: Re: [PATCH v2-resend 10/30] libxc: ocaml: add simple binding for xentoollog (output only). Date: Thu, 29 Aug 2013 16:05:52 +0100 Message-ID: <21023.25424.865394.239529@mariner.uk.xensource.com> References: <1377168678-25492-1-git-send-email-rob.hoes@citrix.com> <1377168678-25492-11-git-send-email-rob.hoes@citrix.com> <21020.50860.225445.174911@mariner.uk.xensource.com> <360717C0B01E6345BCBE64B758E22C2D0E068A@AMSPEX01CL03.citrite.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <360717C0B01E6345BCBE64B758E22C2D0E068A@AMSPEX01CL03.citrite.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Rob Hoes Cc: Ian Campbell , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Rob Hoes writes ("RE: [Xen-devel] [PATCH v2-resend 10/30] libxc: ocaml: add simple binding for xentoollog (output only)."): > [Ian Jackson:] > > Rob Hoes writes ("[Xen-devel] [PATCH v2-resend 10/30] libxc: ocaml: add > > This (and the next two stanzas too) needs to be autogenerated somehow > > from the list in xentoollog.h. Otherwise people will add levels in > > xentoollog.h and the ocaml code will go wrong. > > This would have been quite easy if the debug levels were part of the libxl IDL. Unfortunately they aren't, because xentoollog is part of libxc. So what options do we have? Adding some sort of IDL to libxc would be one. Or indeed parsing xentoollog.h to derive the log levels, but I think the risk of that going wrong due to changes in xentoollog.h may defeat its purpose. I think we can promise not to break the syntax too badly. Please do parse the information out of xentoollog.h. > > > +let create name cbs : handle = > > > + (* Callback names are supposed to be unique *) > > > + let suffix = string_of_int (Random.int 1000000) in > > > > Surely this can't be a good way to go about it. > > (Won't this fail at least one time in 1E6 ?) > > Most likely this function would be called just once, or at most a few times, in the lifetime of the application, so it won't be that bad. But it would probably be better to just use a counter instead of a random value, and raise a proper exception when we hit 1e6 (or some other larger number). Yes. Or one 64-bit counter. > > Why are you reimplementing in ocaml the stdio logging support from > > xenttoollog ? Surely you'd want to simply call > > xtl_createlogger_stdiostream ? > > I suppose we could do that indeed. Yes :-). Unless there's some reason not to do that, that I'm missing. Thanks, Ia.