|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.senn.magic.logging.SimpleLogger
public class SimpleLogger
This class contains a small and easy to use logger. This logger is not threadsafe so it should only be used in straightforward singlethreaded applications!
| Field Summary | |
|---|---|
static String |
DATE_NOW_DETAILED
Date pattern: yyyy-MM-dd HH:mm:ss |
static String |
DATE_NOW_SHORT
Date pattern: yyyyMMdd |
protected String |
location
|
protected Class |
logClass
|
protected File |
logFile
|
protected String |
name
|
| Constructor Summary | |
|---|---|
SimpleLogger()
Constructs an instance of SimpleLogger with default settings |
|
SimpleLogger(Class logClass)
Constructs an instance of SimpleLogger |
|
SimpleLogger(String location)
Constructs an instance of SimpleLogger |
|
SimpleLogger(String name,
Class logClass,
String location)
Constructs an instance of SimpleLogger |
|
| Method Summary | |
|---|---|
protected void |
createLogFile()
Protected method that creates the logfile. |
protected void |
doLog(String message,
String type)
Protected method that does the actual logging. |
void |
error(String errorMessage)
Logs an error message to the logfile (provided in Constructor) |
protected static String |
generateDate(String dateFormat)
Protected method that generates the current date in the format you supply |
String |
getLocation()
Gets the location of the logfile |
Class |
getLogClass()
Gets the class in which the logging occurs |
File |
getLogFile()
Gets the file associated with the logfile |
String |
getName()
Gets the name of the logfile |
void |
log(String message)
Logs a message to the logfile (provided in Constructor) |
protected static String |
now()
Protected method that generates the current time in a yyyy-MM-dd HH:mm:ss format. |
protected void |
setLocation(String location)
Sets the location of the logfile |
protected void |
setLogClass(Class logClass)
Sets the class in which the logging occurs |
protected void |
setName(String name)
Sets the name of the logfile |
protected static String |
today()
Protected method that generates the current time in a yyyyMMdd format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DATE_NOW_DETAILED
yyyy-MM-dd HH:mm:ss
public static final String DATE_NOW_SHORT
yyyyMMdd
protected String location
protected Class logClass
protected String name
protected File logFile
| Constructor Detail |
|---|
public SimpleLogger(String name,
Class logClass,
String location)
SimpleLogger
name - name of the logfile (the logfile will be named name_yyyyMMdd.log)logClass - the class in which the logging occurs - can be left nulllocation - location where the logfile should be placed - if left null it will be placed in the classpath
public SimpleLogger(Class logClass)
SimpleLogger
logClass - the class in which the logging occurs - can be left nullpublic SimpleLogger(String location)
SimpleLogger
location - location where the logfile should be placed - if left null it
will be placed in the classpath
public SimpleLogger()
SimpleLogger with default settings
| Method Detail |
|---|
public void log(String message)
message - message to be loggedpublic void error(String errorMessage)
errorMessage - error message to be logged
protected void doLog(String message,
String type)
message - the message you want to logtype - the type of logging - you see this in between brackets:
[ERROR], [DEBUG], [WARN], [INFO], ...protected static String now()
yyyy-MM-dd HH:mm:ss format.
generateDate(SimpleLogger.DATE_NOW_DETAILED);
String - the current time in a yyyyMMdd formatprotected static String today()
yyyyMMdd format.
generateDate(SimpleLogger.DATE_NOW_SHORT);
String - the current time in a yyyyMMdd formatprotected static String generateDate(String dateFormat)
dateFormat - the date format
String - the current date in the provided formatprotected void createLogFile()
public String getLocation()
String - the location of the logfileprotected void setLocation(String location)
location - the location of the logfile (exclude the logfile's name)public Class getLogClass()
Class - the class which does the loggingprotected void setLogClass(Class logClass)
logClass - the class that will do the loggingpublic String getName()
String - the name of the logfileprotected void setName(String name)
name - the name of the logfilepublic File getLogFile()
File - the logfile as a File object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||