improved sibaCLI and removed final for each logger
This commit is contained in:
parent
36e8196940
commit
43f4afb004
@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class Siba
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Siba.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(Siba.class);
|
||||
|
||||
public static void main(final String[] args)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class SibaCLI
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(SibaCLI.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(SibaCLI.class);
|
||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.cli.messages"); //$NON-NLS-1$
|
||||
|
||||
public static void backup(final File directoryToSave) throws SibaException
|
||||
@ -97,6 +97,34 @@ public class SibaCLI
|
||||
System.out.println("siba check [filename | filename.tgz | filename.tgz.md5]");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void manageSibaCLIException()
|
||||
{
|
||||
// Set default CLI catch.
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@Override
|
||||
public void uncaughtException(final Thread thread, final Throwable exception)
|
||||
{
|
||||
String message;
|
||||
if (exception instanceof OutOfMemoryError)
|
||||
{
|
||||
message = "Java ran out of memory!\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "An error occured: " + exception.getClass() + "(" + exception.getMessage() + ")";
|
||||
}
|
||||
|
||||
logger.error("uncaughtException ", exception);
|
||||
logger.error(message);
|
||||
logger.info(BUNDLE.getString("UnexpectedError.text"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This method launch CLI.
|
||||
@ -105,9 +133,9 @@ public class SibaCLI
|
||||
*/
|
||||
public static void run(final String[] args)
|
||||
{
|
||||
sibaCLIException();
|
||||
try
|
||||
{
|
||||
manageSibaCLIException();
|
||||
// This part implements an automate.
|
||||
int parameterCount = args.length;
|
||||
if (parameterCount == 0)
|
||||
@ -181,31 +209,4 @@ public class SibaCLI
|
||||
help();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void sibaCLIException()
|
||||
{
|
||||
// Set default CLI catch.
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@Override
|
||||
public void uncaughtException(final Thread thread, final Throwable exception)
|
||||
{
|
||||
String message;
|
||||
if (exception instanceof OutOfMemoryError)
|
||||
{
|
||||
message = "Java ran out of memory!\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "An error occured: " + exception.getClass() + "(" + exception.getMessage() + ")";
|
||||
}
|
||||
|
||||
logger.error("uncaughtException ", exception);
|
||||
logger.error(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -10,3 +10,4 @@ missingTargetFile.text=missing target file
|
||||
NotDirectorySource.text=Source is not a directory
|
||||
SibaManageralgorithm.text=Algorithm error in sibaManagerexception
|
||||
ToManyParameter.text= Bad number of parameters
|
||||
UnexpectedError.text = An error occur, contact your administrator
|
@ -10,3 +10,4 @@ missingTargetFile.text=Le r
|
||||
NotDirectorySource.text=La source n'est pas un répertoire
|
||||
SibaManageralgorithm.text=Erreur d'algorithme dans sibaManager
|
||||
ToManyParameter.text= Trop de paramètres
|
||||
UnexpectedError.text= Une erreur s'est produite, contactez votre administrateur
|
@ -21,7 +21,7 @@ public class CheckDirectorySelector extends JFileChooser
|
||||
{
|
||||
private static final long serialVersionUID = 3782597353602048214L;
|
||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
|
||||
private static final Logger logger = LoggerFactory.getLogger(CheckDirectorySelector.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(CheckDirectorySelector.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,7 +57,7 @@ public class CheckPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 4495957907349664847L;
|
||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
|
||||
public static final Logger logger = LoggerFactory.getLogger(CheckPanel.class);
|
||||
public static Logger logger = LoggerFactory.getLogger(CheckPanel.class);
|
||||
private JTextField fileToCheckField;
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,7 @@ import org.slf4j.LoggerFactory;
|
||||
public class SibaGUI
|
||||
{
|
||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
|
||||
public static final Logger logger = LoggerFactory.getLogger(SibaGUI.class);
|
||||
public static Logger logger = LoggerFactory.getLogger(SibaGUI.class);
|
||||
private JFrame frmSimpleBackup;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ public class SourceDirectorySelector extends JFileChooser
|
||||
{
|
||||
private static final long serialVersionUID = 3782597353602048214L;
|
||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
|
||||
public static final Logger logger = LoggerFactory.getLogger(SourceDirectorySelector.class);
|
||||
public static Logger logger = LoggerFactory.getLogger(SourceDirectorySelector.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,7 +19,7 @@ public class TargetDirectorySelector extends JFileChooser
|
||||
{
|
||||
private static final long serialVersionUID = 3782597353602048214L;
|
||||
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
|
||||
public static final Logger logger = LoggerFactory.getLogger(TargetDirectorySelector.class);
|
||||
public static Logger logger = LoggerFactory.getLogger(TargetDirectorySelector.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user