Migrate to SLF4J.
This commit is contained in:
parent
f4307c754c
commit
cb0d17104f
28 changed files with 98 additions and 85 deletions
|
@ -8,5 +8,7 @@
|
|||
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.5.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -2,3 +2,5 @@ Description of used libraries:
|
|||
- hamcrest-core: required by junit
|
||||
- junit: unit tests API
|
||||
- log4j: log API
|
||||
- slf4j-api: facade log API
|
||||
- slf4j-log4j12: adaptation layer between slf4j and log4j
|
||||
|
|
BIN
lib/slf4j-api-1.7.5-sources.jar
Normal file
BIN
lib/slf4j-api-1.7.5-sources.jar
Normal file
Binary file not shown.
BIN
lib/slf4j-api-1.7.5.jar
Normal file
BIN
lib/slf4j-api-1.7.5.jar
Normal file
Binary file not shown.
BIN
lib/slf4j-log4j12-1.7.5-sources.jar
Normal file
BIN
lib/slf4j-log4j12-1.7.5-sources.jar
Normal file
Binary file not shown.
BIN
lib/slf4j-log4j12-1.7.5.jar
Normal file
BIN
lib/slf4j-log4j12-1.7.5.jar
Normal file
Binary file not shown.
|
@ -17,8 +17,8 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class DateHelper
|
||||
{
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (DateHelper.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(DateHelper.class);
|
||||
|
||||
static final String EUROPEAN_DATE_FORMAT = "%02d/%02d/%04d";
|
||||
static final String SHORT_EUROPEAN_DATE_FORMAT = "%02d/%02d";
|
||||
|
|
|
@ -7,13 +7,13 @@ package fr.devinsy.util;
|
|||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
/**
|
||||
* This class groups function to help in Calendar manipulation.
|
||||
*/
|
||||
public class DateTimeHelper
|
||||
{
|
||||
//static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger (DateTimeHelper.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(DateTimeHelper.class);
|
||||
|
||||
static final String EUROPEAN_DATE_FORMAT = "%02d/%02d/%04d %02d:%02d:%02d";
|
||||
static final String RAW_DATE_FORMAT = "%04d%02d%02d %02d:%02d:%02d";
|
||||
|
@ -25,11 +25,10 @@ public class DateTimeHelper
|
|||
static final String ISO_DATE_PATTERN = "^(\\d\\d\\d\\d)-([01]\\d)-([0123]\\d)$";
|
||||
static final String AMERICAN_DATE_PATTERN = "^([01]{0,1}\\d)/([0123]{0,1}\\d)/(\\d\\d\\d\\d)$";
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static public String europeanFormat (Calendar time)
|
||||
static public String americanFormat(final Calendar time)
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -39,23 +38,18 @@ public class DateTimeHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
result = String.format (EUROPEAN_DATE_FORMAT, time.get(Calendar.DAY_OF_MONTH),
|
||||
time.get(Calendar.MONTH) + 1,
|
||||
time.get(Calendar.YEAR),
|
||||
time.get(Calendar.HOUR_OF_DAY),
|
||||
time.get(Calendar.MINUTE),
|
||||
time.get(Calendar.SECOND));
|
||||
result = String.format(AMERICAN_DATE_FORMAT, time.get(Calendar.MONTH) + 1, time.get(Calendar.DAY_OF_MONTH), time.get(Calendar.YEAR), time.get(Calendar.HOUR_OF_DAY),
|
||||
time.get(Calendar.MINUTE), time.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
//
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static public String ISOFormat (Calendar time)
|
||||
static public String europeanFormat(final Calendar time)
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -65,23 +59,18 @@ public class DateTimeHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
result = String.format (ISO_DATE_FORMAT, time.get(Calendar.YEAR),
|
||||
time.get(Calendar.MONTH) + 1,
|
||||
time.get(Calendar.DAY_OF_MONTH),
|
||||
time.get(Calendar.HOUR_OF_DAY),
|
||||
time.get(Calendar.MINUTE),
|
||||
time.get(Calendar.SECOND));
|
||||
result = String.format(EUROPEAN_DATE_FORMAT, time.get(Calendar.DAY_OF_MONTH), time.get(Calendar.MONTH) + 1, time.get(Calendar.YEAR), time.get(Calendar.HOUR_OF_DAY),
|
||||
time.get(Calendar.MINUTE), time.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
//
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static public String americanFormat (Calendar time)
|
||||
static public String ISOFormat(final Calendar time)
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -91,23 +80,18 @@ public class DateTimeHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
result = String.format (AMERICAN_DATE_FORMAT, time.get(Calendar.MONTH) + 1,
|
||||
time.get(Calendar.DAY_OF_MONTH),
|
||||
time.get(Calendar.YEAR),
|
||||
time.get(Calendar.HOUR_OF_DAY),
|
||||
time.get(Calendar.MINUTE),
|
||||
time.get(Calendar.SECOND));
|
||||
result = String.format(ISO_DATE_FORMAT, time.get(Calendar.YEAR), time.get(Calendar.MONTH) + 1, time.get(Calendar.DAY_OF_MONTH), time.get(Calendar.HOUR_OF_DAY), time.get(Calendar.MINUTE),
|
||||
time.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
//
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static public String rawFormat (Calendar time)
|
||||
static public String rawFormat(final Calendar time)
|
||||
{
|
||||
String result;
|
||||
|
||||
|
@ -117,12 +101,8 @@ public class DateTimeHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
result = String.format (RAW_DATE_FORMAT, time.get(Calendar.YEAR),
|
||||
time.get(Calendar.MONTH) + 1,
|
||||
time.get(Calendar.DAY_OF_MONTH),
|
||||
time.get(Calendar.HOUR_OF_DAY),
|
||||
time.get(Calendar.MINUTE),
|
||||
time.get(Calendar.SECOND));
|
||||
result = String.format(RAW_DATE_FORMAT, time.get(Calendar.YEAR), time.get(Calendar.MONTH) + 1, time.get(Calendar.DAY_OF_MONTH), time.get(Calendar.HOUR_OF_DAY), time.get(Calendar.MINUTE),
|
||||
time.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package fr.devinsy.util.cmdexec;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.StringConcatenator;
|
||||
|
||||
/**
|
||||
|
@ -8,7 +11,7 @@ import fr.devinsy.util.StringConcatenator;
|
|||
*/
|
||||
public class CmdExec
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(CmdExec.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(CmdExec.class);
|
||||
|
||||
protected int exitValue;
|
||||
protected String out;
|
||||
|
|
|
@ -5,12 +5,15 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class StreamGobbler extends Thread
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(CmdExec.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(CmdExec.class);
|
||||
|
||||
static final public int NONE = 0;
|
||||
static final public int PRINT = 1;
|
||||
|
|
|
@ -5,13 +5,16 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Wrapper
|
||||
{
|
||||
static private final Wrapper instance = new Wrapper();
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Wrapper.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(Wrapper.class);
|
||||
|
||||
/**
|
||||
* return instance of the controller
|
||||
|
|
|
@ -2,6 +2,9 @@ package fr.devinsy.util.unix;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -12,7 +15,7 @@ public class CachedFile
|
|||
NOT_LOAD, EXPIRED, UPDATED
|
||||
}
|
||||
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(CachedFile.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(CachedFile.class);
|
||||
|
||||
protected String sourceName;
|
||||
protected long sourceTime;
|
||||
|
|
|
@ -7,8 +7,8 @@ import java.util.Vector;
|
|||
*/
|
||||
public class EtcGroupFile extends CachedFile
|
||||
{
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (EtcGroupFile.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(EtcGroupFile.class);
|
||||
|
||||
static EtcGroupFile instance = null;
|
||||
protected Groups groups;
|
||||
|
|
|
@ -4,12 +4,15 @@ import java.io.BufferedReader;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EtcGroupFileReader
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(EtcGroupFileReader.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(EtcGroupFileReader.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package fr.devinsy.util.unix;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EtcPasswdFile extends CachedFile
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(EtcPasswdFile.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(EtcPasswdFile.class);
|
||||
|
||||
static EtcPasswdFile instance = null;
|
||||
protected Users users;
|
||||
|
|
|
@ -4,12 +4,15 @@ import java.io.BufferedReader;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EtcPasswdFileReader
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(EtcPasswdFileReader.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(EtcPasswdFileReader.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -7,8 +7,8 @@ import java.util.Vector;
|
|||
*/
|
||||
public class Group
|
||||
{
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (Group.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(Group.class);
|
||||
|
||||
/*
|
||||
* /usr/include/grp.h
|
||||
|
|
|
@ -11,8 +11,8 @@ public class Groups extends Vector<Group>
|
|||
|
||||
private static final long serialVersionUID = 5802487312198869603L;
|
||||
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (Groups.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(Groups.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -3,6 +3,9 @@ package fr.devinsy.util.unix;
|
|||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.StringConcatenator;
|
||||
import fr.devinsy.util.cmdexec.CmdExec;
|
||||
import fr.devinsy.util.unix.acl.Acl;
|
||||
|
@ -13,7 +16,7 @@ import fr.devinsy.util.unix.acl.AclManager;
|
|||
*/
|
||||
public class Unix
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Unix.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(Unix.class);
|
||||
static public final String SUDO = "/usr/bin/sudo";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package fr.devinsy.util.unix;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class User
|
||||
{
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (User.class);
|
||||
// static private final Logger logger = LoggerFactory.getLogger(User.class);
|
||||
|
||||
/*
|
||||
* /usr/include/pwd.h
|
||||
|
|
|
@ -10,8 +10,8 @@ public class Users extends Vector<User>
|
|||
{
|
||||
private static final long serialVersionUID = -7178304512851592399L;
|
||||
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (Users.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(Users.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -5,8 +5,7 @@ package fr.devinsy.util.unix.acl;
|
|||
*/
|
||||
public class Acl
|
||||
{
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (Acl.class);
|
||||
// static private final Logger logger = LoggerFactory.getLogger(Acl.class);
|
||||
|
||||
/*
|
||||
# file: goo39
|
||||
|
|
|
@ -10,8 +10,8 @@ public class AclEntries extends Vector<AclEntry>
|
|||
{
|
||||
private static final long serialVersionUID = 5802487312198869603L;
|
||||
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (AclEntries.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(AclEntries.class);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package fr.devinsy.util.unix.acl;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AclEntry
|
||||
{
|
||||
// static private org.apache.log4j.Logger logger =
|
||||
// org.apache.log4j.Logger.getLogger (AclEntry.class);
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(AclEntry.class);
|
||||
|
||||
/*
|
||||
user::rwx
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.io.File;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.StringConcatenator;
|
||||
import fr.devinsy.util.cmdexec.CmdExec;
|
||||
import fr.devinsy.util.unix.Unix;
|
||||
|
@ -13,7 +16,7 @@ import fr.devinsy.util.unix.Unix;
|
|||
*/
|
||||
public class AclManager
|
||||
{
|
||||
static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(AclManager.class);
|
||||
static private final Logger logger = LoggerFactory.getLogger(AclManager.class);
|
||||
static public final String SUDO = "/usr/bin/sudo";
|
||||
|
||||
static final public Pattern USER_PATTERN = Pattern.compile("^user:(.*):(.*)$");
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.cmdexec.CmdExec;
|
||||
import fr.devinsy.util.cmdexec.StreamGobbler;
|
||||
|
||||
|
@ -6,30 +11,26 @@ import fr.devinsy.util.cmdexec.StreamGobbler;
|
|||
*/
|
||||
class CmdExecPlayer
|
||||
{
|
||||
static private org.apache.log4j.Logger logger;
|
||||
static private final Logger logger;
|
||||
|
||||
static
|
||||
{
|
||||
// Initialize logger.
|
||||
org.apache.log4j.Logger logger = null;
|
||||
|
||||
org.apache.log4j.BasicConfigurator.configure();
|
||||
org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO);
|
||||
|
||||
logger = org.apache.log4j.Logger.getRootLogger();
|
||||
// logger.setLevel (org.apache.log4j.Level.INFO);
|
||||
logger.setLevel(org.apache.log4j.Level.INFO);
|
||||
|
||||
logger = LoggerFactory.getLogger(CmdExecPlayer.class);
|
||||
logger.info("Enter");
|
||||
|
||||
//
|
||||
logger.info("Set the log file format...");
|
||||
org.apache.log4j.Logger defaultLogger = org.apache.log4j.Logger.getRootLogger();
|
||||
defaultLogger.removeAllAppenders();
|
||||
defaultLogger.addAppender(new ConsoleAppender(new PatternLayout("%d{ISO8601} - dutils [%-5p] %34.34c.%-25M - %m%n")));
|
||||
|
||||
// log =
|
||||
// org.apache.log4j.Category.getInstance(Application.class.getName());
|
||||
logger.info("... done.");
|
||||
|
||||
logger.debug("Exit");
|
||||
logger = org.apache.log4j.Logger.getLogger(CmdExecPlayer.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import java.io.File;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.util.FileIterator;
|
||||
|
||||
|
@ -12,22 +12,23 @@ import fr.devinsy.util.FileIterator;
|
|||
*/
|
||||
public class FileIteratorPlayer
|
||||
{
|
||||
static private org.apache.log4j.Logger logger;
|
||||
static private final Logger logger;
|
||||
|
||||
static
|
||||
{
|
||||
// Initialize logger.
|
||||
org.apache.log4j.BasicConfigurator.configure();
|
||||
org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
|
||||
|
||||
BasicConfigurator.configure();
|
||||
Logger defaultLogger = org.apache.log4j.Logger.getRootLogger();
|
||||
defaultLogger.setLevel(org.apache.log4j.Level.DEBUG);
|
||||
logger = LoggerFactory.getLogger(CmdExecPlayer.class);
|
||||
|
||||
//
|
||||
org.apache.log4j.Logger defaultLogger = org.apache.log4j.Logger.getRootLogger();
|
||||
defaultLogger.removeAllAppenders();
|
||||
defaultLogger.addAppender(new ConsoleAppender(new PatternLayout("%d{ISO8601} - FIT [%-5p] %34.34c.%-25M - %m%n")));
|
||||
defaultLogger.addAppender(new ConsoleAppender(new PatternLayout("%d{ISO8601} - dutils [%-5p] %34.34c.%-25M - %m%n")));
|
||||
|
||||
defaultLogger.debug("Log initialized.");
|
||||
|
||||
logger = org.apache.log4j.Logger.getLogger(FileIteratorPlayer.class.getName());
|
||||
//
|
||||
logger.debug("Log initialized.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.junit.Test;
|
|||
|
||||
public class Foo2Test
|
||||
{
|
||||
// private Logger logger =
|
||||
// static private final Logger logger =
|
||||
// LoggerFactory.getLogger(PdfGenerationAmqpServiceInjectedTest.class);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue