OSDN Git Service

printStackTraceの場所をLoggerに置き換え
authoryukihane <yukihane.feather@gmail.com>
Sun, 21 Aug 2011 22:02:04 +0000 (07:02 +0900)
committeryukihane <yukihane.feather@gmail.com>
Sun, 21 Aug 2011 22:02:04 +0000 (07:02 +0900)
frontend/src/saccubus/Saccubus.java
frontend/src/saccubus/conv/Chat.java
frontend/src/saccubus/conv/ConvertToVideoHook.java
frontend/src/saccubus/converter/Converter.java
frontend/src/saccubus/net/NicoClientImpl.java
frontend/src/saccubus/util/FileDropTarget.java
frontend/src/yukihane/inqubus/gui/MainFrame.java

index 4310f3e..526857c 100644 (file)
@@ -1,6 +1,8 @@
 package saccubus;
 
 import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 
@@ -28,6 +30,8 @@ import yukihane.inqubus.gui.MainFrame;
  * @version 1.0
  */
 public class Saccubus {
+
+    private static final Logger logger = Logger.getLogger(Saccubus.class.getName());
        boolean packFrame = false;
 
        /**
@@ -71,7 +75,7 @@ public class Saccubus {
                                        UIManager.setLookAndFeel(UIManager
                                                        .getSystemLookAndFeelClassName());
                                } catch (Exception exception) {
-                                       exception.printStackTrace();
+                                       logger.log(Level.SEVERE, null, exception);
                                }
 
                                new Saccubus();
index 0b9f7b0..5dbcdff 100644 (file)
@@ -215,7 +215,7 @@ public class Chat {
                try {
                        a = (Comment + "\0").getBytes("UnicodeLittleUnmarked");
                } catch (UnsupportedEncodingException ex) {
-                       ex.printStackTrace();
+                       logger.log(Level.SEVERE, null, ex);
                }
                IOUtil.writeInt(os, No);
                IOUtil.writeInt(os, Vpos);
@@ -226,7 +226,7 @@ public class Chat {
                try {
                        os.write(a);
                } catch (IOException ex1) {
-                       ex1.printStackTrace();
+                       logger.log(Level.SEVERE, null, ex1);
                }
        }
 
index f136d92..c0c3038 100644 (file)
@@ -1,6 +1,8 @@
 package saccubus.conv;
 
 import java.io.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.xml.sax.*;
 import javax.xml.parsers.*;
 
@@ -25,6 +27,9 @@ import javax.xml.parsers.*;
  * @version 1.0
  */
 public class ConvertToVideoHook {
+
+    private static final Logger logger = Logger.getLogger(ConvertToVideoHook.class.getName());
+
        public static boolean convert(File file, File out, String ng_id,
                        String ng_word) {
                try {
@@ -38,7 +43,7 @@ public class ConvertToVideoHook {
                        try {
                                nico_reader = new NicoXMLReader(packet, ng_id, ng_word);
                        } catch (java.util.regex.PatternSyntaxException e) {
-                               e.printStackTrace();
+                               logger.log(Level.SEVERE, null, e);
                                return false;
                        }
                        if (nico_reader != null) {
@@ -50,11 +55,11 @@ public class ConvertToVideoHook {
                        fos.close();
                        return true;
                } catch (IOException ex) {
-                       ex.printStackTrace();
+                       logger.log(Level.SEVERE, null, ex);
                } catch (SAXException ex) {
-                       ex.printStackTrace();
+                       logger.log(Level.SEVERE, null, ex);
                } catch (ParserConfigurationException ex) {
-                       ex.printStackTrace();
+                       logger.log(Level.SEVERE, null, ex);
                }
                return false;
        }
index e372f9b..ce1ceb8 100644 (file)
@@ -4,6 +4,8 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.concurrent.Callable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import nicobrowser.GetFlvResult;
 import nicobrowser.NamePattern;
 import nicobrowser.NicoHttpClient;
@@ -34,6 +36,7 @@ import saccubus.converter.profile.ProxyProfile;
  */
 public class Converter extends AbstractCommand implements Callable<Boolean> {
 
+    private static final Logger logger = Logger.getLogger(Converter.class.getName());
     private final Profile profile;
     private final String movieId;
 
@@ -70,7 +73,7 @@ public class Converter extends AbstractCommand implements Callable<Boolean> {
         } catch (Exception ex) {
             String text = (ex.getMessage() != null) ? ex.getMessage() : "予期しないエラー発生のため中断しました。";
             sendText(text);
-            ex.printStackTrace();
+            logger.log(Level.SEVERE, null, ex);
         }
     }
 
index 7c09a20..f6363c5 100644 (file)
@@ -12,15 +12,17 @@ import java.net.URL;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.net.Proxy;
-import java.net.URLEncoder;
 import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.net.ssl.HttpsURLConnection;
+import nicobrowser.util.Util;
 import saccubus.ConvertStopFlag;
+import saccubus.net.VideoInfo.OfficialOption;
 import saccubus.util.FileUtil;
-import yukihane.Util;
-import static saccubus.net.VideoInfo.OfficialOption;
 
 /**
  * <p>
@@ -45,6 +47,7 @@ import static saccubus.net.VideoInfo.OfficialOption;
 @Deprecated
 public class NicoClientImpl implements NicoClient {
 
+    private static final Logger logger = Logger.getLogger(NicoClientImpl.class.getName());
     private String Cookie = null;
     private final String User;
     private final String Pass;
@@ -163,7 +166,7 @@ public class NicoClientImpl implements NicoClient {
             con.disconnect();
             return file;
         } catch (IOException ex) {
-            ex.printStackTrace();
+            logger.log(Level.SEVERE, null, ex);
         }
         return null;
     }
@@ -230,9 +233,9 @@ public class NicoClientImpl implements NicoClient {
             con.disconnect();
             return outFile;
         } catch (FileNotFoundException ex) {
-            ex.printStackTrace();
+            logger.log(Level.SEVERE, null, ex);
         } catch (IOException ex) {
-            ex.printStackTrace();
+            logger.log(Level.SEVERE, null, ex);
         }
         return null;
     }
@@ -351,7 +354,7 @@ public class NicoClientImpl implements NicoClient {
             con.disconnect();
         } catch (IOException ex1) {
             System.out.println("ng.");
-            ex1.printStackTrace();
+            logger.log(Level.SEVERE, null, ex1);
             throw ex1;
         }
 
@@ -426,7 +429,7 @@ public class NicoClientImpl implements NicoClient {
             }
             System.out.println("Logged in.");
         } catch (IOException ex) {
-            ex.printStackTrace();
+            logger.log(Level.SEVERE, null, ex);
             return false;
         }
         return true;
index 1e3b684..50e37d8 100644 (file)
@@ -8,6 +8,8 @@ import java.awt.dnd.*;
 import java.io.File;
 import java.io.IOException;
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.swing.JTextField;
 
 /**
@@ -15,6 +17,9 @@ import javax.swing.JTextField;
  *
  */
 public class FileDropTarget extends DropTargetAdapter {
+
+    private static final Logger logger = Logger.getLogger(FileDropTarget.class.getName());
+
        private final JTextField Field;
 
        private final boolean isFolder;
@@ -60,9 +65,9 @@ public class FileDropTarget extends DropTargetAdapter {
                                dtde.dropComplete(true);
                        }
                } catch (UnsupportedFlavorException e) {
-                       e.printStackTrace();
+                       logger.log(Level.SEVERE, null, e);
                } catch (IOException e) {
-                       e.printStackTrace();
+                       logger.log(Level.SEVERE, null, e);
                }
        }
 
index 1841dbe..d9ab6ca 100644 (file)
@@ -13,6 +13,8 @@ import java.io.File;
 import java.io.FilenameFilter;
 import java.util.Collection;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import javax.swing.JButton;
@@ -20,7 +22,6 @@ import javax.swing.JTextField;
 import javax.swing.TransferHandler;
 import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
-import org.apache.commons.io.FilenameUtils;
 import yukihane.inqubus.conifg.Properties;
 import yukihane.inqubus.model.Target;
 import yukihane.inqubus.model.TargetsTableModel;
@@ -32,6 +33,7 @@ import yukihane.inqubus.model.TargetsTableModel;
 public class MainFrame extends javax.swing.JFrame {
 
     private static final long serialVersionUID = 1L;
+    private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
     private final TargetsTableModel targetModel = new TargetsTableModel();
 
     /** Creates new form MainFrame */
@@ -478,7 +480,7 @@ private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_
                 }
                 return false;
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.log(Level.SEVERE, null, e);
                 return false;
             }
         }