Compare commits
No commits in common. "316d22aecd52e17e352b97b1c48854966ec7c3e3" and "9cd09831ff67bd661b71727aad8a79faab64b23d" have entirely different histories.
316d22aecd
...
9cd09831ff
4 changed files with 29 additions and 157 deletions
|
@ -395,7 +395,7 @@ public final class Logar
|
|||
}
|
||||
else if (!file.isFile())
|
||||
{
|
||||
throw new IllegalArgumentException("Parameter is not a file [" + file + "]");
|
||||
throw new IllegalArgumentException("Parameter is not a file.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -458,31 +458,13 @@ public final class Logar
|
|||
}
|
||||
else if (!source.exists())
|
||||
{
|
||||
System.out.println("Missing source to check [" + source + "]");
|
||||
System.out.println("Missing source to check.");
|
||||
}
|
||||
else
|
||||
{
|
||||
checkLogFiles(new Files(source));
|
||||
}
|
||||
}
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).sortByName();
|
||||
|
||||
/**
|
||||
* Check log files.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static void checkLogFiles(final Files source) throws IOException
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (File file : source)
|
||||
for (File file : files)
|
||||
{
|
||||
checkLogFile(file);
|
||||
}
|
||||
|
@ -505,7 +487,7 @@ public final class Logar
|
|||
}
|
||||
else if (!source.exists())
|
||||
{
|
||||
System.out.println("Missing source to check [" + source + "]");
|
||||
System.out.println("Missing source to check.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -518,29 +500,6 @@ public final class Logar
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check sort.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static void checkSort(final Files source) throws IOException
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (File file : source)
|
||||
{
|
||||
checkSortFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check sort file.
|
||||
*
|
||||
|
@ -692,31 +651,12 @@ public final class Logar
|
|||
}
|
||||
else if (!source.exists())
|
||||
{
|
||||
System.out.println("Missing source to sort [" + source + "]");
|
||||
System.out.println("Missing source to sort.");
|
||||
}
|
||||
else
|
||||
{
|
||||
identify(new Files(source));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static void identify(final Files source) throws IOException
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (File file : source)
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).removeHidden().sortByName();
|
||||
for (File file : files)
|
||||
{
|
||||
String type = LogFile.getType(file);
|
||||
|
||||
|
@ -741,31 +681,13 @@ public final class Logar
|
|||
}
|
||||
else if (!source.exists())
|
||||
{
|
||||
System.out.println("Missing source to sort [" + source + "]");
|
||||
System.out.println("Missing source to sort.");
|
||||
}
|
||||
else
|
||||
{
|
||||
sort(new Files(source));
|
||||
}
|
||||
}
|
||||
Files files = FilesUtils.search(source, LOGFILE_PATTERN).removeHidden().sortByName();
|
||||
|
||||
/**
|
||||
* Sort.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @throws IOException
|
||||
* Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public static void sort(final Files source) throws IOException
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
System.out.println("Undefined source.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (File file : source)
|
||||
for (File file : files)
|
||||
{
|
||||
System.out.println("== Sort for [" + file.getName() + "]");
|
||||
LogFile.sortLogFile(file);
|
||||
|
@ -781,18 +703,9 @@ public final class Logar
|
|||
*/
|
||||
public static void statUserAgents(final File source)
|
||||
{
|
||||
statUserAgents(new Files(source));
|
||||
}
|
||||
Files files = FilesUtils.searchEndingWith(source, ".log", ".log.gz").keepFileType().sortByName();
|
||||
|
||||
/**
|
||||
* Stat user agents.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
*/
|
||||
public static void statUserAgents(final Files source)
|
||||
{
|
||||
for (File file : source)
|
||||
for (File file : files)
|
||||
{
|
||||
statUserAgentsForFile(file);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.PrintWriter;
|
|||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -239,7 +238,7 @@ public final class LogFile
|
|||
PrintWriter out = null;
|
||||
try
|
||||
{
|
||||
if (StringUtils.endsWithAny(target.getName(), ".gz", ".gz.tmp"))
|
||||
if (target.getName().endsWith(".gz"))
|
||||
{
|
||||
out = new PrintWriter(new GZIPOutputStream(new FileOutputStream(target)));
|
||||
}
|
||||
|
|
|
@ -167,26 +167,16 @@ public final class LogarCLI
|
|||
|
||||
Logar.archive(source, target, OnOffOption.ON);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "check", ".+"))
|
||||
else if (CLIUtils.isMatching(args, "check", ".+"))
|
||||
{
|
||||
Files source = new Files();
|
||||
for (int index = 1; index < args.length; index++)
|
||||
{
|
||||
File file = new File(args[index]);
|
||||
Files filteredFiles = FilesUtils.search(file, Logar.LOGFILE_PATTERN).keepFileType().sortByName();
|
||||
source.addAll(filteredFiles);
|
||||
}
|
||||
File source = new File(args[1]);
|
||||
|
||||
Logar.checkLogFiles(source);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "checksort", ".+"))
|
||||
else if (CLIUtils.isMatching(args, "checksort", ".+"))
|
||||
{
|
||||
Files source = new Files();
|
||||
for (int index = 1; index < args.length; index++)
|
||||
{
|
||||
File file = new File(args[index]);
|
||||
Files filteredFiles = FilesUtils.search(file, Logar.LOGFILE_PATTERN).keepFileType().sortByName();
|
||||
source.addAll(filteredFiles);
|
||||
}
|
||||
File source = new File(args[1]);
|
||||
|
||||
Logar.checkSort(source);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "extract", "\\s*((ip)?(,)?(remoteuser)?(,)?(datetime)?(,)?(useragent)?)\\s*", "\\s*\\S+\\s*"))
|
||||
|
@ -196,37 +186,22 @@ public final class LogarCLI
|
|||
|
||||
Logar.extract(source, options);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "identify", ".+"))
|
||||
else if (CLIUtils.isMatching(args, "identify", ".+"))
|
||||
{
|
||||
Files source = new Files();
|
||||
for (int index = 1; index < args.length; index++)
|
||||
{
|
||||
File file = new File(args[index]);
|
||||
Files filteredFiles = FilesUtils.search(file, Logar.LOGFILE_PATTERN).keepFileType().sortByName();
|
||||
source.addAll(filteredFiles);
|
||||
}
|
||||
File source = new File(args[1]);
|
||||
|
||||
Logar.identify(source);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "sort", ".+"))
|
||||
else if (CLIUtils.isMatching(args, "sort", ".+"))
|
||||
{
|
||||
Files source = new Files();
|
||||
for (int index = 1; index < args.length; index++)
|
||||
{
|
||||
File file = new File(args[index]);
|
||||
Files filteredFiles = FilesUtils.search(file, Logar.LOGFILE_PATTERN).keepFileType().sortByName();
|
||||
source.addAll(filteredFiles);
|
||||
}
|
||||
File source = new File(args[1]);
|
||||
|
||||
Logar.sort(source);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "statuseragent", ".+"))
|
||||
else if (CLIUtils.isMatching(args, "statuseragent", ".+"))
|
||||
{
|
||||
Files source = new Files();
|
||||
for (int index = 1; index < args.length; index++)
|
||||
{
|
||||
File file = new File(args[index]);
|
||||
Files filteredFiles = FilesUtils.search(file, Logar.LOGFILE_PATTERN).keepFileType().sortByName();
|
||||
source.addAll(filteredFiles);
|
||||
}
|
||||
File source = new File(args[1]);
|
||||
|
||||
Logar.statUserAgents(source);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "testconcate", ".+"))
|
||||
|
|
|
@ -38,21 +38,6 @@ public class Files extends ArrayList<File>
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new files.
|
||||
*
|
||||
* @param file
|
||||
* the file
|
||||
*/
|
||||
public Files(final File file)
|
||||
{
|
||||
super();
|
||||
if (file != null)
|
||||
{
|
||||
add(file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new files.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue