[liblouis-liblouisxml] Re: The liblouis logging functions

  • From: Michael Whapples <mwhapples@xxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Tue, 19 Jun 2012 13:24:07 +0100

Hello,
One slight correction to what you said: If lou_logFile is called with a null parameter then a crash occurs. The error messages are output to STDERR if no call to lou_logFile is made.

I agree with your general plan, however I think the meaning of passing NULL to lou_logFile needs more defining.

Consider the following case:
* A call to lou_logFile is made
* calls to lou_logPrint are made
* Another call to lou_logFile is made with a different file name
* More calls to lou_logPrint are made

What should happen with that second call to lou_logFile? Should it simply ignore it and return an error value because a log file has already been defined? Should the second call enable the application to change the log file used?

Particularly what should a second call to lou_logFile do if the parameter is NULL on the second call? If a second call normally would change the log file should a call with NULL switch it back to STDERR?

Michael Whapples
On 19/06/2012 12:59, John J. Boyer wrote:
There are three such functions, lou_logfile lolu_logPrint and lou_logEnd
They must be considered as a group. The question on this thread is what
behavior is best. Thanks to Michael for bringing this to my attention.

Right now, if the argument to lou_logfile is NULL messages are sent to
stderr. This causes problems on a GUI. If the application doesn't crash
the messages may just not be displayed. An obvious fix is to make
lou_logfile ignore NULL arguments. Lou_logPrint also needs some fixing.
lou_logEnd closes the log file so it is available for examination by the
user or the application.

I think that if lou_logfile is called with a valid filename, it should
save that name, and ignore any NULL arguments. When lou_logPrint is
called
it should check for a filename and if one is present open that file if
it is not already open. Thus, an application can give a filename when it
starts and this file will be used no matter how many times the file is
closed. I plan to do this in BrailleBlaster. The initialize method
provides a filename which is appended to the path to the brlblst/temp
directory on the user's machine. Calls to liblouisutdml functions will
then send error messages to this file.

Thanks,
John



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

Other related posts: