[brailleblaster] Re: Debugging

  • From: Michael Whapples <mwhapples@xxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Mon, 28 Feb 2011 10:36:24 +0000

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



Other related posts: