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

  • From: "Michael Whapples" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "mwhapples@xxxxxxx" for DMARC)
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Thu, 22 May 2014 08:56:49 +0100

Hello,
Thanks for that. It is very much what I was thinking.

I had just been hoping for a better way to do that initialisation, as I said like static initialisers in Java, but it seems like C has no such concept.

As for liblouisutdml having initialisation code duplication, may be but I don't want to make the situation worse, but may be then this is the chance to work on cleaning that up.

Michael Whapples
On 21/05/2014 18:29, Bert Frees wrote:
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

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

Other related posts: