// You can force EurekaLog to generate bug report in some other format.
// Obviously, there is no such build-in feature in EurekaLog.
// Here is a simple code that creates bug report in format of EurekaLog 6 (with less columns in call stack).
// Naturally, you may replace the whole code by overriding TBaseLogBuilder.BuildReport method.
// See also: https://www.eurekalog.com/downloads_extras.php
// This sample uses a combination of custom class and event handler to reach the desired goal.
uses
EConsts, ETypes, EClasses, ECallStack, EException, EEvents, ELogBuilder;
type
// EurekaLog 6 format will be altered from default EurekaLog 7 format,
// that's why we inherit from EurekaLog 7 builder class and
// replace only some methods
TEurekaLog6Builder = class(TLogBuilder)
public
function CreateGeneralText: String; override;
function CreateCallStackText: String; override;
end;
{ TEurekaLog6Builder }
// Replace header of the bug report (to change "7" to "6" in header)
function TEurekaLog6Builder.CreateGeneralText: String;
begin
Result := inherited;
Result := 'EurekaLog 6' + Copy(Result, Pos(sLineBreak, Result), MaxInt);
end;
// Replace call stack (remove new columns)
function TEurekaLog6Builder.CreateCallStackText: String;
var
Stack: TEurekaCallStack;
Formatter: TEurekaBaseStackFormatter;
begin
Stack := nil;
try
if CallStack <> nil then
begin
Stack := TEurekaCallStack.Create;
Stack.Assign(CallStack);
Stack.Formatter.Assign(Options);
Stack.Formatter.CaptionHeader :=
Options.CustomizedExpandedTexts[mtDialog_CallStackHeader] + EHeaderSuffix;
end;
Formatter := TEurekaStackFormatterV6.Create;
try
Formatter.Assign(Options);
Formatter.CaptionHeader :=
Options.CustomizedExpandedTexts[mtDialog_CallStackHeader] + EHeaderSuffix;
Result := CallStackToString(Stack,
Options.CustomizedExpandedTexts[mtDialog_CallStackHeader] + EHeaderSuffix,
Formatter);
finally
FreeAndNil(Formatter);
end;
finally
FreeAndNil(Stack);
end;
end;
// Rename .el files to old .elf files
procedure CustomizeFileNames(const ACustom: Pointer; AExceptionInfo: TEurekaExceptionInfo;
const AFileType: TEurekaLogFileType; var AFileName: String; var ACallNextHandler: Boolean);
begin
if AnsiLowerCase(ExtractFileExt(AFileName)) = '.el' then
AFileName := ChangeFileExt(AFileName, '.elf');
end;
initialization
// Register bug report builder:
LogBuilderClass := TEurekaLog6Builder;
// Register event handler for file names:
RegisterEventCustomFileName(nil, CustomizeFileNames);
end.
Comments