Issue#24 improved log policy

This commit is contained in:
Didier Clermonté 2016-06-21 15:05:12 +02:00
parent ae7271cdd5
commit 3eadf7330a
5 changed files with 39 additions and 40 deletions

View File

@ -173,13 +173,13 @@ public class SibaCLI
}
}
catch (SibaException sibaException)
catch (SibaException exception)
{
System.err.println("SibaException = " + sibaException.getMessage());
sibaException.printStackTrace();
if (sibaException.getCause() != null)
System.err.println("SibaException = " + exception.getMessage());
logger.error(exception.getMessage(), exception);
if (exception.getCause() != null)
{
logger.info("SibaException chainée = " + sibaException.getCause().getMessage());
logger.error("SibaException chainée = " + exception.getCause().getMessage());
}
help();
}

View File

@ -35,6 +35,9 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author dclermonte
@ -43,6 +46,7 @@ import javax.swing.JTextPane;
public class AboutDialog extends JDialog
{
private static final long serialVersionUID = 8868109575782482455L;
public static final Logger logger = LoggerFactory.getLogger(SibaGUI.class);
/**
* This is the constructor for the dialog.
@ -105,9 +109,9 @@ public class AboutDialog extends JDialog
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
}
catch (Exception e)
catch (Exception exception)
{
e.printStackTrace();
logger.error("Exception ", exception);
}
}
}

View File

@ -180,12 +180,12 @@ public class BackupPanel extends JPanel
JOptionPane.INFORMATION_MESSAGE);
}
}
catch (SibaException sibaException)
catch (SibaException exception)
{
String dataMissing = sibaException.getMessage();
if (sibaException.getCause() != null)
String dataMissing = exception.getMessage();
if (exception.getCause() != null)
{
dataMissing.concat(sibaException.getCause().getMessage());
dataMissing = dataMissing.concat(exception.getCause().getMessage());
}
String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text");

View File

@ -35,6 +35,8 @@ import javax.swing.JTextField;
import org.dclermonte.siba.SibaException;
import org.dclermonte.siba.model.SibaManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
@ -51,6 +53,7 @@ public class CheckPanel extends JPanel
{
private static final long serialVersionUID = -1580485684838045920L;
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
public static final Logger logger = LoggerFactory.getLogger(CheckPanel.class);
private JTextField fileToCheckField;
private File choosenFile;
@ -75,10 +78,8 @@ public class CheckPanel extends JPanel
JLabel lblNewLabel = new JLabel(BUNDLE.getString("CheckPanel.lblNewLabel.text")); //$NON-NLS-1$
add(lblNewLabel, "2, 2, left, center");
JButton btnNewButton = new JButton(BUNDLE.getString("CheckPanel.btnNewButton.text")); //$NON-NLS-1$
btnNewButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
File choosenFile;
btnNewButton.addActionListener(new ActionListener()
{
@Override
@ -88,15 +89,13 @@ public class CheckPanel extends JPanel
{
CheckPanel.this.choosenFile = choosenDirectory();
}
catch (IOException e1)
catch (IOException exception)
{
// TODO Auto-generated catch block
e1.printStackTrace();
logger.error("IOexception ", exception);
}
catch (NoSuchAlgorithmException e1)
catch (NoSuchAlgorithmException exception)
{
// TODO Auto-generated catch block
e1.printStackTrace();
logger.error("NoSuchAlgorithm ", exception);
}
}
});
@ -145,8 +144,7 @@ public class CheckPanel extends JPanel
}
catch (SibaException exception)
{
// TODO Auto-generated catch block
exception.printStackTrace();
logger.error("SibaException ", exception);
}
}
});

View File

@ -68,7 +68,7 @@ public class SibaGUI
/**
* Launch the application.
*/
Locale locale;
private Locale locale;
private BackupPanel backupPanel;
private CheckPanel checkPanel;
@ -104,7 +104,7 @@ public class SibaGUI
JOptionPane.showMessageDialog(SibaGUI.this.frmSimpleBackup, message, "Error",
JOptionPane.ERROR_MESSAGE);
exception.printStackTrace();
logger.error("uncaughtException ", exception);
}
});
@ -176,11 +176,12 @@ public class SibaGUI
tabbedPane.addTab(BUNDLE.getString("BackupPanel.TitleBackupPanel.text"), //$NON-NLS-1$
new ImageIcon(SibaGUI.class.getResource("/org/dclermonte/siba/gui/SibaLogo.png")), this.backupPanel,
null);
CheckPanel checkPanel = new CheckPanel();
checkPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
checkPanel.setBackground(new Color(144, 238, 144));
this.checkPanel = new CheckPanel();
this.checkPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
this.checkPanel.setBackground(new Color(144, 238, 144));
tabbedPane.addTab(BUNDLE.getString("BackupPanel.TitleCheckPanel.text"), //$NON-NLS-1$
new ImageIcon(SibaGUI.class.getResource("/org/dclermonte/siba/gui/SibaLogo.png")), checkPanel, null);
new ImageIcon(SibaGUI.class.getResource("/org/dclermonte/siba/gui/SibaLogo.png")), this.checkPanel,
null);
this.frmSimpleBackup.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
this.frmSimpleBackup.setForeground(new Color(0, 100, 0));
this.frmSimpleBackup.setBackground(new Color(102, 205, 170));
@ -208,7 +209,7 @@ public class SibaGUI
public void actionPerformed(final ActionEvent e)
{
tabbedPane.setSelectedIndex(0);
File file = SourceDirectorySelector.showSelectorDialog(null, null);
File file = SourceDirectorySelector.showSelectorDialog(SibaGUI.this.backupPanel, null);
if (file != null)
{
SibaGUI.this.backupPanel.setSourceDirectory(file.getPath());
@ -226,14 +227,11 @@ public class SibaGUI
public void actionPerformed(final ActionEvent e)
{
tabbedPane.setSelectedIndex(1);
File choosenFile = CheckDirectorySelector.showSelectorDialog(null, null);
File choosenFile = CheckDirectorySelector.showSelectorDialog(SibaGUI.this.checkPanel, null);
if ((choosenFile != null) && choosenFile.exists())
{
SibaGUI.this.checkPanel.setFileToCheck(choosenFile.getName());
}
else
{
}
}
});
mnFile.add(mntmCheck);
@ -313,21 +311,20 @@ public class SibaGUI
SibaGUI window = new SibaGUI();
window.frmSimpleBackup.setVisible(true);
}
catch (SibaException sibaException)
catch (SibaException exception)
{
sibaException.printStackTrace();
String dataMissing = sibaException.getMessage();
if (sibaException.getCause() != null)
logger.error("SibaException ", exception);
String dataMissing = exception.getMessage();
if (exception.getCause() != null)
{
logger.info("SibaException chainée = " + sibaException.getCause().getMessage());
// dataMissing.concat(sibaException.getCause().getMessage());
logger.info("SibaException chainée = " + exception.getCause().getMessage());
}
String titleWarning = BUNDLE.getString("BackupPanel.TitleWarning.text");
JOptionPane.showMessageDialog(null, dataMissing, titleWarning, JOptionPane.INFORMATION_MESSAGE);
}
catch (Exception e)
catch (Exception exception)
{
e.printStackTrace();
logger.error("Exception ", exception);
}
}
});