[brailleblaster] Re: Is it possible to show a stack trace in a dialog box?

  • From: "Michael Whapples" <mwhapples@xxxxxxx>
  • To: <brailleblaster@xxxxxxxxxxxxx>
  • Date: Fri, 16 Mar 2012 13:39:55 -0000

OK, I have taken a quick look, you're using the Java logging API. A quick, but not recommended way you could do it from other classes would be to assign a Logger with the following line:

Logger logger = Logger.getLogger("org.brailleblaster");
Works as this will return a reference to the existing logger used in BBIni.
The above is not recommended simply on the account that the name used for the logger (the String being passed to the Logger.getLogger(String) method) should be the class name, which would allow precise control on logging output (eg. allowing one to only get logging output for one class or package or set one class or package to a different logging level to the rest or even have different logging outputs for different parts of the application). You haven't followed that recommendation in the BBIni class already.

Here is a more recommended way of doing things, it will answer the questions you have posed up to now http://www.vogella.de/articles/Logging/article.html

However I would also recommend looking at using configuration files for configuring the loggers, need to find a tutorial covering that.

Michael Whapples

-----Original Message----- From: John J. Boyer
Sent: Thursday, March 15, 2012 5:45 PM
To: brailleblaster@xxxxxxxxxxxxx
Subject: [brailleblaster] Re: Is it possible to show a stack trace in a dialog box?

Thanks. I have set up the logger, but it only reports problems that
occur in BBIni. How do I get it to repoet problems in other classes?
Perhaps an error message could offer the user the option of viewing the
log.

John

On Thu, Mar 15, 2012 at 04:06:10PM -0000, Michael Whapples wrote:
Hello,
Firstly I would say that in general stack traces should never be shown to
users, stack traces probably are only really meaningful to developers. May
be if there is an error message appear a details button may reveal debug
information which may include a stack trace, however we should try and
provide a more helpful message wherever possible to help users. An error
dialog may offer a way to let the user send debug information to
developers, but we probably would want more than just a stack trace, so may
be a section of the log output for just before the exception was raised
could be sent as well.

Anyway, to deal with the actual question, refer to the javadoc for
Exception, which really doesn't add much over Throwable, so here's the link
for Throwable's javadoc for Java6
http://docs.oracle.com/javase/6/docs/api/java/lang/Throwable.html

If you were wanting to write to a stream of some sort then the
printStackTrace methods may be relevant as there are methods which can take
PrintWriter or PrintStream. If you want greater programatic control/access
to the stack trace then look at the method getStackTrace() which gets an
array of the StackTraceElements, you would need to deal with
StackTraceElement yourself to create the String in the form you want.

Michael Whapples

-----Original Message----- From: John J. Boyer
Sent: Thursday, March 15, 2012 12:01 PM
To: brailleblaster@xxxxxxxxxxxxx
Subject: [brailleblaster] Is it possible to show a stack trace in a dialog
box?

This would be a big help to development oif one is using the GUI and
something bad happens. The trace would have to be captured as a String
and then passed to a method in Documentmanager. This method would in
turn display it in a SWT MessageBox with an OK button or perhaps with
the option to continue.

More generally. liblouis and liblouisutdml were designed to be their own
developmennt tools. How can this be applied to BrailleBlaster?

Thanks,
John

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



--
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: