Root > How to... > ...redefine Bug ID?

...redefine Bug ID?

Previous pageReturn to chapter overviewNext page   

BugID is a 4-byte unsigned integer (LongWord) which is used to identify exception, for example: 76BA0000. Two exception with the same BugID value are considered to be the same. Two bug reports are considered to be duplicates of each other if they are bug reports about exceptions with the same BugID. BugID is used to establish uniqueness for many EurekaLog features.

 

BugID is constructed based on options of your project. If you want to customize BugID - try to change EurekaLog project options first.

 

However, you may also redefine default behavior by any custom code. For example:

 

 

1. Append BugID

The code example below will "append" BugID. In other words, it takes default value from EurekaLog and adds additional "restrictions". For example, if you want to make the same exception from two different machines to be different exceptions - you can add/append machine ID to BugID.

 

uses
  EException, // for TEurekaExceptionInfo
  EHash,      // for GetCRC16
  ESysInfo,   // for GetComputerName, GetUserName, etc.
  EEvents;    // for RegisterEventCustomBugID
 
initialization
 
// Changes BugID for a given exception
procedure DefineCustomBugID(const ACustom: Pointer;

  AExceptionInfo: TEurekaExceptionInfo; 

  var ABugID, ACustomBugID: Word; 

  var ACallNextHandler: Boolean);
var
  HashSource: String;
begin
  // Select sources which will define additional "unique" details

  // The code below is just an example, you can use any code you want

  HashSource :=
    GetComputerName + #1 +
    GetUserName + #1 +
    GetWindowsPath + #1 +

 
    GetEurekaLogVersion + #1;

 
  ACustomBugID := GetCRC16(HashSource);
end;
 
initialization
  // Ask EurekaLog to ask us about BugIDs
  RegisterEventCustomBugID(nil, DefineCustomBugID);
  // Requires the 
  // "Allow EurekaLog to use user-defined "custom" low word" 
  // option to be UNCHECKED
end.

 

 

2. Replace BugID

The code example below will replace BugID. In other words, it will discard EurekaLog-defined BugID and use your value. This is useful if you want to completely redefine BugID.

 

uses
  ELowLevel,  // for PtrToOffset
  EException, // for TEurekaExceptionInfo
  EHash,      // for GetCRC16
  ESysInfo,   // for GetComputerName, GetUserName, etc.
  EEvents;    // for RegisterEventCustomBugID
 
initialization
 
// Constructs BugID for a given exception
procedure DefineBugID(const ACustom: Pointer;

  AExceptionInfo: TEurekaExceptionInfo; 

  var ABugID, ACustomBugID: Word; 

  var ACallNextHandler: Boolean);
var
  HashSource: String;
begin
  // Select sources which will define additional "unique" details

  // The code below is just an example, you can use any code you want

  // Please note that the example below establishes most unique ID possible: 

  // each exception will be unique - due to using "Now".

  // There will be no merging at all.

  HashSource :=

    IntToHex(PtrToOffset(AExceptionInfo.Address), SizeOf(Pointer) * 2) + #1 +
    AExceptionInfo.ExceptionMessage + #1 +

 
    GetComputerName + #1 +
    GetUserName + #1 +
    GetWindowsPath + #1 +

 
    DateTimeToStr(Now) + #1 +

 
    DateTimeToStr(GetCurrentModuleCompilationDate) + #1 +
    GetEurekaLogVersion + #1;

 
  ABugID := GetCRC32(HashSource);

  ACustomBugID := ABugID;
end;
 
initialization
  // Ask EurekaLog to ask us about BugIDs
  RegisterEventCustomBugID(nil, DefineBugID);
  // Requires the 
  // "Allow EurekaLog to use user-defined "custom" low word" 
  // option to be UNCHECKED
end.

 

 

See also:




Send feedback... Build date: 2024-12-19
Last edited: 2023-08-09
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/how_to_redefine_bug_id.php