Selaa lähdekoodia

SLF4J Logging in DCC plugin.

pull/413/head
Greg Holmes 9 vuotta sitten
vanhempi
commit
4f3039fe6e

+ 10
- 6
dcc/src/com/dmdirc/addons/dcc/DCCManager.java Näytä tiedosto

@@ -48,7 +48,6 @@ import com.dmdirc.config.prefs.PreferencesSetting;
48 48
 import com.dmdirc.config.prefs.PreferencesType;
49 49
 import com.dmdirc.events.ClientPrefsOpenedEvent;
50 50
 import com.dmdirc.events.ServerCtcpEvent;
51
-import com.dmdirc.events.UserErrorEvent;
52 51
 import com.dmdirc.interfaces.CommandController;
53 52
 import com.dmdirc.interfaces.Connection;
54 53
 import com.dmdirc.interfaces.User;
@@ -56,7 +55,6 @@ import com.dmdirc.interfaces.WindowModel;
56 55
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
57 56
 import com.dmdirc.interfaces.config.ConfigProvider;
58 57
 import com.dmdirc.interfaces.config.IdentityController;
59
-import com.dmdirc.logger.ErrorLevel;
60 58
 import com.dmdirc.parser.interfaces.Parser;
61 59
 import com.dmdirc.plugins.PluginDomain;
62 60
 import com.dmdirc.plugins.PluginInfo;
@@ -83,14 +81,20 @@ import javax.swing.JComponent;
83 81
 import javax.swing.JFileChooser;
84 82
 import javax.swing.JOptionPane;
85 83
 
84
+import org.slf4j.Logger;
85
+import org.slf4j.LoggerFactory;
86
+
86 87
 import net.engio.mbassy.listener.Handler;
87 88
 
89
+import static com.dmdirc.util.LogUtils.USER_ERROR;
90
+
88 91
 /**
89 92
  * This plugin adds DCC to DMDirc.
90 93
  */
91 94
 @Singleton
92 95
 public class DCCManager {
93 96
 
97
+    private static final Logger LOG = LoggerFactory.getLogger(DCCManager.class);
94 98
     private final BackBufferFactory backBufferFactory;
95 99
     /** Our DCC Container window. */
96 100
     private PlaceholderContainer container;
@@ -710,16 +714,16 @@ public class DCCManager {
710 714
                 "receive.savelocation"));
711 715
         if (dir.exists()) {
712 716
             if (!dir.isDirectory()) {
713
-                eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, null,
714
-                        "Unable to create download dir (file exists instead)", ""));
717
+                LOG.info(USER_ERROR, "Unable to create download dir (file exists instead)",
718
+                        new IllegalArgumentException("Directory is really a file"));
715 719
             }
716 720
         } else {
717 721
             try {
718 722
                 dir.mkdirs();
719 723
                 dir.createNewFile();
720 724
             } catch (IOException ex) {
721
-                eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, null,
722
-                        "Unable to create download dir", ""));
725
+                LOG.info(USER_ERROR, "Unable to create download dir",
726
+                        new IllegalArgumentException("Unable to create download dir"));
723 727
             }
724 728
         }
725 729
 

+ 10
- 8
dcc/src/com/dmdirc/addons/dcc/ui/TransferPanel.java Näytä tiedosto

@@ -28,10 +28,8 @@ import com.dmdirc.addons.dcc.TransferContainer;
28 28
 import com.dmdirc.addons.dcc.io.DCCTransfer;
29 29
 import com.dmdirc.addons.ui_swing.UIUtilities;
30 30
 import com.dmdirc.addons.ui_swing.components.frames.SwingFrameComponent;
31
-import com.dmdirc.events.UserErrorEvent;
32 31
 import com.dmdirc.interfaces.Connection;
33 32
 import com.dmdirc.interfaces.WindowModel;
34
-import com.dmdirc.logger.ErrorLevel;
35 33
 import com.dmdirc.parser.events.SocketCloseEvent;
36 34
 import com.dmdirc.parser.interfaces.Parser;
37 35
 import com.dmdirc.util.DateUtils;
@@ -49,8 +47,13 @@ import javax.swing.JProgressBar;
49 47
 
50 48
 import net.miginfocom.swing.MigLayout;
51 49
 
50
+import org.slf4j.Logger;
51
+import org.slf4j.LoggerFactory;
52
+
52 53
 import net.engio.mbassy.listener.Handler;
53 54
 
55
+import static com.dmdirc.util.LogUtils.USER_ERROR;
56
+
54 57
 /**
55 58
  * A panel for displaying the progress of DCC transfers.
56 59
  *
@@ -59,6 +62,7 @@ import net.engio.mbassy.listener.Handler;
59 62
 public class TransferPanel extends JPanel implements ActionListener,
60 63
         DCCTransferHandler, SwingFrameComponent {
61 64
 
65
+    private static final Logger LOG = LoggerFactory.getLogger(TransferPanel.class);
62 66
     /** A version number for this class. */
63 67
     private static final long serialVersionUID = 1L;
64 68
     /** Parent container. */
@@ -150,19 +154,17 @@ public class TransferPanel extends JPanel implements ActionListener,
150 154
             try {
151 155
                 Desktop.getDesktop().open(file);
152 156
             } catch (IllegalArgumentException ex) {
153
-                errorBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
154
-                        "Unable to open file: " + file, ""));
157
+                LOG.info(USER_ERROR, "Unable to open file {}", file.getAbsolutePath(), ex);
155 158
                 openButton.setEnabled(false);
156 159
             } catch (IOException ex) {
157 160
                 try {
158 161
                     Desktop.getDesktop().open(file.getParentFile());
159 162
                 } catch (IllegalArgumentException ex1) {
160
-                    errorBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex1, "Unable to open folder: "
161
-                            + file.getParentFile(), ""));
163
+                    LOG.info(USER_ERROR, "Unable to open folder: {}",
164
+                            file.getParentFile().getAbsolutePath(), ex1);
162 165
                     openButton.setEnabled(false);
163 166
                 } catch (IOException ex1) {
164
-                    errorBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex1,
165
-                            "No associated handler to open file or directory.", ""));
167
+                    LOG.info(USER_ERROR, "No associated handler to open file or directory.", ex1);
166 168
                     openButton.setEnabled(false);
167 169
                 }
168 170
             }

Loading…
Peruuta
Tallenna