Revision: af82029a84b1 Branch: default Author: Brandon Roller <brandon.r.roller@xxxxxxxxx> Date: Wed Jul 17 08:37:13 2013 Log: Added logging calls to ctach blocks http://code.google.com/p/brailleblaster/source/detail?r=af82029a84b1&repo=newdesign Modified: /src/main/org/brailleblaster/util/CheckLiblouisutdmlLog.java /src/main/org/brailleblaster/wordprocessor/BBDocument.java /src/main/org/brailleblaster/wordprocessor/BBSemanticsTable.java /src/main/org/brailleblaster/wordprocessor/DocumentManager.java /src/main/org/brailleblaster/wordprocessor/Normalizer.java =======================================--- /src/main/org/brailleblaster/util/CheckLiblouisutdmlLog.java Wed Jan 30 22:57:48 2013 +++ /src/main/org/brailleblaster/util/CheckLiblouisutdmlLog.java Wed Jul 17 08:37:13 2013
@@ -36,14 +36,10 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.MessageBox; import org.brailleblaster.BBIni; -import org.brailleblaster.localization.LocaleHandler; import org.brailleblaster.wordprocessor.WPManager; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.FileNotFoundException; -import java.io.FileInputStream; import java.io.FileReader; import java.io.BufferedReader; @@ -56,7 +52,7 @@ String logFileName; public CheckLiblouisutdmlLog () { -logFileName = BBIni.getLogFilesPath() + BBIni.getFileSep() + +logFileName = BBIni.getTempFilesPath() + BBIni.getFileSep() + "liblouisutdml.log"; } =======================================--- /src/main/org/brailleblaster/wordprocessor/BBDocument.java Tue Jul 16 12:40:18 2013 +++ /src/main/org/brailleblaster/wordprocessor/BBDocument.java Wed Jul 17 08:37:13 2013
@@ -32,9 +32,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.PrintWriter; import java.io.StringReader; -import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.net.ConnectException; import java.net.UnknownHostException; @@ -143,34 +141,29 @@ catch(ConnectException e){new Notify("Brailleblaster failed to access necessary materials from online. Please check your internet connection and try again.");
e.printStackTrace(); - printErrors(e); + logger.log(Level.SEVERE, "Connections Error", e); return false; } catch(UnknownHostException e){new Notify("Brailleblaster failed to access necessary materials from online. Please check your internet connection and try again.");
e.printStackTrace(); - printErrors(e); + logger.log(Level.SEVERE, "Unknown Host Error", e); return false; } catch (ParsingException e) { new Notify("Problem processing " + fileName + " See stack trace."); + new CheckLiblouisutdmlLog().displayLog(); e.printStackTrace(); - printErrors(e); + logger.log(Level.SEVERE, "Parse Error", e); return false; } catch (IOException e) {new Notify ("IO error occurred while parsing " + fileName + " See stack trace.");
e.printStackTrace(); - printErrors(e); + logger.log(Level.SEVERE, "IO Error", e); return false; } } - - private void printErrors(Exception e){ - StringWriter errors = new StringWriter(); - e.printStackTrace(new PrintWriter(errors)); - logger.log(Level.SEVERE, errors.toString()); - } private void normalizeFile(String originalFilePath, String tempFilePath){ Normalizer n = new Normalizer(originalFilePath); @@ -420,6 +413,7 @@ } catch (UnsupportedEncodingException e) { e.printStackTrace(); + logger.log(Level.SEVERE, "Unsupported Encoding Exception", e); return -1; } } @@ -556,6 +550,7 @@ } catch (IOException e) { e.printStackTrace(); + logger.log(Level.SEVERE, "IO Exception", e); } return ""; @@ -586,6 +581,7 @@ return false; } catch(Exception ex){ + logger.log(Level.SEVERE, "Exception", ex); return false; } } =======================================--- /src/main/org/brailleblaster/wordprocessor/BBSemanticsTable.java Wed Jul 10 05:34:57 2013 +++ /src/main/org/brailleblaster/wordprocessor/BBSemanticsTable.java Wed Jul 17 08:37:13 2013
@@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.Map.Entry; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import org.brailleblaster.BBIni; import org.brailleblaster.util.Notify; @@ -71,11 +73,12 @@ Document doc; HashMap<String,Styles> table; + static Logger logger = BBIni.getLogger(); public BBSemanticsTable(){ try { this.table = new HashMap<String, Styles>();- FileReader file = new FileReader(BBIni.getProgramDataPath() + BBIni.getFileSep() + "liblouisutdml" + BBIni.getFileSep() + "lbu_files" + BBIni.getFileSep() + "preferences.cfg"); + FileReader file = new FileReader(BBIni.getProgramDataPath() + BBIni.getFileSep() + "liblouisutdml" + BBIni.getFileSep() + "lbu_files" + BBIni.getFileSep() + BBIni.getDefaultConfigFile());
BufferedReader reader = new BufferedReader(file); makeHashTable(reader); reader.close(); @@ -86,7 +89,8 @@ } catch(Exception e){ e.printStackTrace();- new Notify("The application failed to load due to errors in preferences.cfg"); + new Notify("The application failed to load due to errors in " + BBIni.getDefaultConfigFile());
+ logger.log(Level.SEVERE, "Config File Error", e); } } =======================================--- /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Mon Jul 15 11:47:33 2013 +++ /src/main/org/brailleblaster/wordprocessor/DocumentManager.java Wed Jul 17 08:37:13 2013
@@ -252,7 +252,6 @@ } private void initializeAllViews(String fileName, String filePath){ -// long start = System.currentTimeMillis(); try{if(this.document.startDocument(filePath, BBIni.getDefaultConfigFile(), null)){
this.group.setRedraw(false); @@ -288,8 +287,6 @@ catch(Exception e){ e.printStackTrace(); } -// long end = System.currentTimeMillis(); -// System.out.println("TOTAL: " + (end - start)); } private void initializeViews(Node current){ @@ -502,6 +499,7 @@ } catch (IOException e) { e.printStackTrace(); + logger.log(Level.SEVERE, "IO Exception", e); } } } @@ -604,13 +602,14 @@ translatedFile.delete(); } catch (PrintException e) {new Notify(lh.localValue("cannotEmboss") + ": " + data.name + "\n" + e.getMessage());
+ logger.log(Level.SEVERE, "Print Exception", e); } } } public void printPreview(){ if(this.braille.view.getCharCount() > 0){ - PrintPreview pv = new PrintPreview(this.getDisplay(), this.document); + new PrintPreview(this.getDisplay(), this.document); } } @@ -699,6 +698,7 @@ } catch (IOException e) {new Notify("An error occurred while refreshing the document. Please save your work and try again.");
e.printStackTrace(); + logger.log(Level.SEVERE, "IO Exception", e); } } @@ -713,14 +713,17 @@ os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); + logger.log(Level.SEVERE, "File Not Found Exception", e); return false; } catch (UnsupportedEncodingException e) { e.printStackTrace(); + logger.log(Level.SEVERE, "Unsupported Encoding Exception", e); return false; } catch (IOException e) { e.printStackTrace(); + logger.log(Level.SEVERE, "IO Exception", e); return false; } return true; @@ -736,6 +739,7 @@ } catch(Exception e){ e.printStackTrace(); + logger.log(Level.SEVERE, "Exception", e); } } =======================================--- /src/main/org/brailleblaster/wordprocessor/Normalizer.java Tue Jul 16 12:40:18 2013 +++ /src/main/org/brailleblaster/wordprocessor/Normalizer.java Wed Jul 17 08:37:13 2013
@@ -1,10 +1,7 @@ package org.brailleblaster.wordprocessor; import java.io.File; -import java.io.FileWriter; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import java.net.ConnectException; import java.net.UnknownHostException; import java.util.logging.Level; @@ -14,10 +11,7 @@ import org.brailleblaster.util.Notify; import org.w3c.dom.Document; -import org.w3c.dom.CDATASection; -import org.w3c.dom.Document; import org.w3c.dom.NodeList; -import org.w3c.dom.Node; import org.w3c.dom.Element; import org.w3c.dom.Text; import org.xml.sax.SAXException; @@ -36,7 +30,7 @@ public class Normalizer { File f; Document doc; - Logger log = BBIni.getLogger(); + static Logger log = BBIni.getLogger(); public Normalizer(String path){ this.f = new File(path); @@ -49,35 +43,29 @@ catch(ConnectException e){new Notify("Brailleblaster failed to access necessary materials from online. Please check your internet connection and try again.");
e.printStackTrace(); - printErrors(e); + log.log(Level.SEVERE, "Connections Error", e); } catch(UnknownHostException e){new Notify("Brailleblaster failed to access necessary materials from online. Please check your internet connection and try again.");
e.printStackTrace(); - printErrors(e); + log.log(Level.SEVERE, "Unknown Host Error", e); } catch (ParserConfigurationException e) {new Notify("An error occurred while reading the document. Please check whehther the document contains vaild XML.");
e.printStackTrace(); - printErrors(e); + log.log(Level.SEVERE, "Parse Error", e); } catch (SAXException e) {new Notify("An error occurred while reading the document. Please check whehther the document contains vaild XML.");
e.printStackTrace(); - printErrors(e); + log.log(Level.SEVERE, "Sax Error", e); } catch (IOException e) { new Notify("An error occurred while reading the document."); e.printStackTrace(); - printErrors(e); + log.log(Level.SEVERE, "IO Error", e); } } - - private void printErrors(Exception e){ - StringWriter errors = new StringWriter(); - e.printStackTrace(new PrintWriter(errors)); - log.log(Level.SEVERE, errors.toString()); - } public void createNewNormalizedFile(String path){ if(this.doc != null){ @@ -124,12 +112,12 @@ StreamResult result = new StreamResult(new File(path)); transformer.transform(source, result); } catch (TransformerConfigurationException e) { - // TODO Auto-generated catch block e.printStackTrace(); + log.log(Level.SEVERE, "Transformer Configuration Exception", e); } catch (TransformerException e) { - // TODO Auto-generated catch block e.printStackTrace(); + log.log(Level.SEVERE, "Transformer Exception", e); }