|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.polliwog.LogCreator
public class LogCreator
Provides some utilities to handling log files. Note: it is likely that the methods in this class will be split into separate tools.
Last Modified By: $Author: barrygently $ Last Modified On: $Date: 2005/07/04 14:00:00 $ Current Revision: $Revision: 1.6 $
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_PAGE_EXTENSIONS
Defines a set of default page extensions. |
static java.lang.String |
MONTH
Defines a value to be used in the splitLog(File,File,String,File,String)
method to split the log file by months. |
static java.lang.String |
TXT
|
Constructor Summary | |
---|---|
LogCreator()
|
Method Summary | |
---|---|
static void |
createSubLog(java.io.File logFile,
java.io.File configFile,
java.util.Date from,
java.util.Date to,
java.io.File outputFile)
Create a sub-log file from the parent log file for entries between the particular dates. |
static Weblog |
createWeblog(java.io.File logFile,
java.io.File configFile)
Create a new instance of Weblog from the specified logfile with the specified
log spec (defined in configFile). |
static Weblog |
createWeblog(java.io.File logFile,
java.io.File configFile,
int lineCount)
Create a new instance of Weblog from the specified logfile with the specified
log spec (defined in configFile) and limit to the specified number of lines (lineCount). |
static int |
cycleOverLog(java.io.File logFile,
java.io.File configFile,
LogEntryListener lel,
java.lang.Class cl)
Cycle over the specified logFile and for each entry in the log create an instance of cl (which must be an extend LogEntry ), this entry is then passed to
lel via the LogEntryListener.processEntry(LogEntry) method. |
static void |
splitLog(java.io.File logFile,
java.io.File configFile,
java.lang.String by,
java.io.File outputDir,
java.lang.String fileExt)
Split a log file in a particular way. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_PAGE_EXTENSIONS
public static final java.lang.String MONTH
splitLog(File,File,String,File,String)
method to split the log file by months.
public static final java.lang.String TXT
Constructor Detail |
---|
public LogCreator()
Method Detail |
---|
public static void splitLog(java.io.File logFile, java.io.File configFile, java.lang.String by, java.io.File outputDir, java.lang.String fileExt) throws java.io.IOException, WeblogException, org.jdom.JDOMException
MONTH
. It should be noted that:
logFile
- The log file that should be split.configFile
- The file (xml format) that contains the log spec.by
- Should be MONTH
.outputDir
- The directory where the separate logs should be created. If the
directory does not exist then it is created.fileExt
- The file extension to give the split logs.
java.io.IOException
- If logFile or configFile do not exist, or if the
logFile cannot be read.
WeblogException
- If something goes wrong with reading a log entry and/or converting
it to a Java representation.
org.jdom.JDOMException
- If there is a problem with the XML format of configFile.LogEntryFormat
,
Hit
public static void createSubLog(java.io.File logFile, java.io.File configFile, java.util.Date from, java.util.Date to, java.io.File outputFile) throws java.io.IOException, WeblogException, org.jdom.JDOMException
logFile
- The log file that should be split.configFile
- The file (xml format) that contains the log spec.from
- The start date.to
- The end date.outputFile
- The file to write the sub-log to. The file is overwritten if it already exists.
java.io.IOException
- If logFile or configFile do not exist, or if the
logFile cannot be read.
WeblogException
- If something goes wrong with reading a log entry and/or converting
it to a Java representation.
org.jdom.JDOMException
- If there is a problem with the XML format of configFile.LogEntryFormat
,
Hit
public static Weblog createWeblog(java.io.File logFile, java.io.File configFile) throws java.io.IOException, WeblogException, org.jdom.JDOMException
Weblog
from the specified logfile with the specified
log spec (defined in configFile).
The Weblog is created using the default page extensions DEFAULT_PAGE_EXTENSIONS
.
For each Hit
created it is added to the Weblog via a call to:
Weblog.addToStats(Hit)
. It should be noted that this method DOES NOT add the
entry to the log, it only increments the statistics.
logFile
- The log file.configFile
- The file (xml format) that contains the log spec.
java.io.IOException
- If the log file or config file cannot be found or read.
WeblogException
- If the log entries cannot be converted to a Hit.
org.jdom.JDOMException
- If the configFile XML format is invalid.LogEntryFormat
,
Hit
,
Weblog
public static Weblog createWeblog(java.io.File logFile, java.io.File configFile, int lineCount) throws java.io.IOException, WeblogException, org.jdom.JDOMException
Weblog
from the specified logfile with the specified
log spec (defined in configFile) and limit to the specified number of lines (lineCount).
The Weblog is created using the default page extensions DEFAULT_PAGE_EXTENSIONS
.
For each Hit
created it is added to the Weblog via a call to:
Weblog.addHit(Hit)
. This means that the Weblog created could be VERY large, use
this method with care.
logFile
- The log file.configFile
- The file (xml format) that contains the log spec.lineCount
- Limit the number of entries added to the specified number, set to -1 to
add all.
java.io.IOException
- If the log file or config file cannot be found or read.
WeblogException
- If the log entries cannot be converted to a Hit.
org.jdom.JDOMException
- If the configFile XML format is invalid.LogEntryFormat
,
Hit
,
Weblog
public static int cycleOverLog(java.io.File logFile, java.io.File configFile, LogEntryListener lel, java.lang.Class cl) throws java.io.IOException, WeblogException, org.jdom.JDOMException
LogEntry
), this entry is then passed to
lel via the LogEntryListener.processEntry(LogEntry)
method.
logFile
- The log file.configFile
- The file (xml format) that contains the log spec.lel
- The LogEntryListener that is used to process the entry.cl
- The class created as a LogEntry.
java.io.IOException
- If the log file or config file cannot be found or read.
WeblogException
- If the log entries cannot be converted to a Hit.
org.jdom.JDOMException
- If the configFile XML format is invalid.LogEntryFormat
,
Hit
,
LogEntry
,
Log
,
Weblog
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |