[brailleblaster] Re: Debugging

  • From: "John J. Boyer" <john.boyer@xxxxxxxxxxxxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Mon, 28 Feb 2011 05:21:18 -0600

The information on logging will be useful. I agree that it is easier to 
put it in when writing the code than later. That is just like 
localization. However, I wonder if logging will deal with what I have in 
mind. For some reason people have had dificulty porting liblouis and 
liblouisutdml for BrailleBlaster, though it has been done several times 
in other contexts. So if the liblouisutdml library is absent I want the 
word processor to advise that the braille facility is missing and to 
give the user the option of continuing. If she choses to do so, the word 
processor will operate normally, except that the only braille 
translation available will be computer braille. This will be very 
valuable for testing and for porting to new platforms. However, I have 
encountered a situation in which liblouisutdml was present but couldn't 
find one of its dependencies. In this case I want to see the message 
from the UnsatisfiedLinkError exception. Can logging handle this 
situation? If the library is completely absent I want the user to be 
able to see what the word processor will do, but if it can't find a 
dependency I want it to throw the exception. It seemed to me that 
-Ddebug-yes on the command line would enable me to do this. Of course, 
I'll also check into including logging.

John

On Mon, Feb 28, 2011 at 10:36:24AM +0000, Michael Whapples wrote:
> Might you really be wanting logging?
> 
> The java logging API in the JDK will probably be sufficient although 
> there are alternatives like log4j, etc.
> 
> Logging has much finer control over what error messages get output and 
> where they go (eg. levels like finest, finer, fine, config, info, 
> warning and severe). I think extra custom levels can be defined although 
> the documentation seems to advise against that unless really needed.
> 
> Also logging allows you to have multiple loggers which can be set to log 
> at different levels (eg. the documentation suggests a logger per class).
> 
> Also it is worth noting the following usage:
> 
> if (logger.isLoggable(Level.FINE)) {
> logger.log(Level.FINE, "Message to be logged");
> }
> 
> While the log method of the Logger class will test if the level allows 
> logging out, the additional if statement may improve performance as it 
> saves any preparation to construct the message (eg. concatenation of 
> strings).
> 
> Configuration of the logging API can be done using system properties or 
> a properties file.
> 
> Also logging was mentioned before to you. Generally logging is easiest 
> to implement at the time of writing the code rather than to add it in later.
> 
> Michael Whapples
> On 28/02/11 08:09, John J. Boyer wrote:
> >First, in response to Michael's last message, BrailleBlaster will
> >present the user with a dialog box asking if she wants to continue,
> >change settings read a startup tutorial, see a quick-start guide, etc.
> >Finallyt it will have a checkbox with the message "Do not show me this
> >message again."
> >
> >On to debugging. Can I call BrailleBlaster with the command:
> >
> >java -Ddebug=yes -jar brailleblaster.jar
> >
> >and later have the code
> >
> >String debug System.getProperty ("debug")
> >
> >The immediate reason for this is that I catch the UnsatisfiedLinkError
> >exception if the liblouisutdml library is not found and set a boolean
> >for the rest of the program. However this error could also be caused if
> >one of its dependencies is not found. In this case I want to see the
> >message. There will certainly be other reasons for wanting a debug flag.
> >
> >Thanks,
> >John
> >
> 

-- 
John J. Boyer; President, Chief Software Developer
Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities


Other related posts: