parent
bd0b6bc3f4
commit
3e3ba96fb9
|
@ -0,0 +1,2 @@
|
||||||
|
lib/
|
||||||
|
*.lps
|
2
UApp.pas
2
UApp.pas
|
@ -250,6 +250,8 @@ begin
|
||||||
Writeln(' specifies the filename with filter commands');
|
Writeln(' specifies the filename with filter commands');
|
||||||
Writeln(' -f --logfile=<filename>');
|
Writeln(' -f --logfile=<filename>');
|
||||||
Writeln(' specifies the logfile to be parsed');
|
Writeln(' specifies the logfile to be parsed');
|
||||||
|
Writeln(' --html=<filename>');
|
||||||
|
Writeln(' outputs filtered results in a formatted HTML file');
|
||||||
Writeln(' -h --help');
|
Writeln(' -h --help');
|
||||||
Writeln(' show this help screen');
|
Writeln(' show this help screen');
|
||||||
end;
|
end;
|
||||||
|
|
48
UWriter.pas
48
UWriter.pas
|
@ -5,7 +5,7 @@ unit UWriter;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, UFilter, crt, fgl;
|
Classes, SysUtils, UFilter, crt, fgl, htmlelements;
|
||||||
|
|
||||||
type
|
type
|
||||||
TWriter = class
|
TWriter = class
|
||||||
|
@ -38,6 +38,18 @@ type
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
const
|
||||||
|
htmlColors: array[0..15] of String[6] = (
|
||||||
|
'000000', '000066', '003300', '0099CC', '990000', '990033', '663300',
|
||||||
|
'CCCCCC', '666666', '66CCFF', '66FF66', '99FFCC', 'FF8080', 'FF80B2',
|
||||||
|
'FFFF00', 'FFFFFF'
|
||||||
|
);
|
||||||
|
cssColors: array[0..15] of String = (
|
||||||
|
'Black', 'Blue', 'Green', 'Cyan', 'Red', 'Magenta', 'Brown', 'LightGray',
|
||||||
|
'DarkGray', 'LightBlue', 'LightGreen', 'LightCyan', 'LightRed',
|
||||||
|
'LightMagenta', 'Yellow', 'White'
|
||||||
|
);
|
||||||
|
|
||||||
{ THTMLWriter }
|
{ THTMLWriter }
|
||||||
|
|
||||||
procedure THTMLWriter.WriteLine(AContent: String);
|
procedure THTMLWriter.WriteLine(AContent: String);
|
||||||
|
@ -50,20 +62,50 @@ constructor THTMLWriter.Create(AFileName: String);
|
||||||
begin
|
begin
|
||||||
FFileStream := TFileStream.Create(AFileName, fmCreate);
|
FFileStream := TFileStream.Create(AFileName, fmCreate);
|
||||||
WriteLine('<html>');
|
WriteLine('<html>');
|
||||||
WriteLine('<body>');
|
WriteLine('<body><samp>');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor THTMLWriter.Destroy;
|
destructor THTMLWriter.Destroy;
|
||||||
begin
|
begin
|
||||||
WriteLine('</body>');
|
WriteLine('</samp></body>');
|
||||||
WriteLine('</html>');
|
WriteLine('</html>');
|
||||||
FFileStream.Free;
|
FFileStream.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THTMLWriter.WriteContent(AContent: String; AHighlights: THighlights);
|
procedure THTMLWriter.WriteContent(AContent: String; AHighlights: THighlights);
|
||||||
|
var
|
||||||
|
matchPos, offset, lastPos: Integer;
|
||||||
|
highlight: THighlight;
|
||||||
|
htmlContent, style: String;
|
||||||
begin
|
begin
|
||||||
|
lastPos := 1;
|
||||||
|
htmlContent := '';
|
||||||
|
|
||||||
|
for highlight in AHighlights do
|
||||||
|
begin
|
||||||
|
matchPos := highlight.Start;
|
||||||
|
offset := highlight.Length;
|
||||||
|
htmlContent := htmlContent + EscapeHTML(Copy(AContent, lastPos,
|
||||||
|
matchPos - lastPos));
|
||||||
|
|
||||||
|
style := '';
|
||||||
|
if highlight.FGColor < 16 then
|
||||||
|
style := 'color: ' + cssColors[highlight.FGColor] + ';';
|
||||||
|
if highlight.BGColor < 15 then
|
||||||
|
style := style + 'background-color: ' + cssColors[highlight.BGColor] + ';';
|
||||||
|
|
||||||
|
if style <> '' then
|
||||||
|
htmlContent := htmlContent + '<span style="' + style + '">';
|
||||||
|
htmlContent := htmlContent + EscapeHTML(Copy(AContent, matchPos, offset));
|
||||||
|
if style <> '' then
|
||||||
|
htmlContent := htmlContent + '</span>';
|
||||||
|
lastPos := matchPos + offset;
|
||||||
|
end;
|
||||||
|
|
||||||
|
htmlContent := htmlContent + EscapeHTML(Copy(AContent, lastPos, Length(AContent)));
|
||||||
|
|
||||||
|
WriteLine(htmlContent + '<br/>');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TConsoleWriter }
|
{ TConsoleWriter }
|
||||||
|
|
Loading…
Reference in New Issue