Extracted file reading

This commit is contained in:
Andreas Schneider 2015-09-25 11:35:16 +02:00
parent c62d4fae0c
commit 1aaf0beb2b
1 changed files with 27 additions and 12 deletions

View File

@ -45,6 +45,9 @@ type
procedure WriteContent(AContent: String; AFilters: TFilterList;
AGroupRanges: TGroupRanges);
procedure FilterLine(ALine: String);
//Logfile handling
procedure DumpFile(AFileName: String);
procedure PollFile(AFileName: String);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -58,7 +61,6 @@ implementation
procedure TLogFilterApplication.DoRun;
var
commandFile: TextFile;
logFile: TextFile;
line: String;
begin
if HasOption('h', 'help') or not HasOption('c', 'commandfile') then
@ -107,17 +109,7 @@ begin
if HasOption('html') then
FWriter.Add(THTMLWriter.Create(GetOptionValue('html')));
AssignFile(logFile, FLogFileName);
Reset(logFile);
// Filter log
while not EOF(logFile) do
begin
Readln(logFile, line);
FilterLine(line);
end;
CloseFile(logFile);
DumpFile(FLogFileName);
// One run is enough.
Terminate;
@ -232,6 +224,29 @@ begin
end;
end;
procedure TLogFilterApplication.DumpFile(AFileName: String);
var
logFile: TextFile;
line: String;
begin
AssignFile(logFile, AFileName);
Reset(logFile);
// Filter log
while not EOF(logFile) do
begin
Readln(logFile, line);
FilterLine(line);
end;
CloseFile(logFile);
end;
procedure TLogFilterApplication.PollFile(AFileName: String);
begin
end;
constructor TLogFilterApplication.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);