[liblouis-liblouisxml] Re: Unsure how to do a change to logging

  • From: Bert Frees <bertfrees@xxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 21 May 2014 19:29:37 +0200

I was thinking something along these lines:

lbu_registerLogCallback(logcallback callback) {
  if (callback == NULL)
    logCallbackFunction = defaultLogCallback;
  else
    logCallbackFunction = callback;
  lou_registerLogCallback(logCallbackFunction);
}

and indeed you would have to put this in the initialization code of
liblouisutdml:

lbu_registerLogCallback(NULL);

I'm not sure where in liblouisutdml it should be best put. I think
the code is already full of duplication of this kind of initialization
stuff, so the maintanence issue is there already.


Michael Whapples writes:

> Hello,
> In changing the logging so that lou_log and lou_logPrint are not public, 
> I have hit a difficulty.
>
> The problem is that in liblouisutdml, how I set a default log handler? 
> This might seem initially simple, just do it in the same way as in 
> liblouis. This however is not enough, it sets a default handler in 
> liblouisutdml but not in liblouis.
>
> You may ask so what is the problem with that? It means that should 
> someone set a file name for the default log handler (eg. 
> lbu_logFilename), this gets set on liblouisutdml but ont on liblouis. 
> Having two handlers accessing one file (one handler in liblouis and one 
> in liblouisutdml) might cause file access problems.
>
> What I need is a C version of a static initialiser (think of static 
> initialisers in Java) where I could call lou_registerLogCallback(NULL) 
> from liblouisutdml.
>
> Failing that, I can only see two possible options:
> 1. Find every public function call in liblouisutdml and do a 
> check/register there. Risk being one will get missed and may become a 
> maintanence issue for the longer term.
> 2. The shared library option I suggested for logging code, then there is 
> only a single storing of the registered callback.
>
> Michael Whapples
> For a description of the software, to download it and links to
> project pages go to http://www.abilitiessoft.com

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: