Root > Solving bugs in your code > Logging > Integrations with 3rd party frameworks > TMS Logging

Using EurekaLog with TMS Logging

Previous pageReturn to chapter overviewNext page   

TMS Logging is a compact cross-platform logging framework offering informative log output to a flexible number of targets with a minimum amount of code.

 

 

TMS Logging to EurekaLog

If you are using TMS Logging in your application - it may be useful to get TMS Logging output as part of your EurekaLog's crash reports, so you will get a better understanding of execution flow of your application before crash.

 

TMS Logging supports custom output handlers, so you may simply redirect all logging from TMS Logging to EurekaLog by:

 

uses
  TMSLoggingEurekaLogOutputHandler;

 

TMSLoggingEurekaLogOutputHandler unit can be found in \Source\Extras\ folder of your EurekaLog installation. You can activate this output handler by using the usual construct:

 

TMSLogger.RegisterOutputHandlerClass(TEurekaLogOutputHandler);

 

This will create EurekaLog log file according to default rules. If you wish to specify file name or location - use ELogOpen function to open log file before registering output handler. In any case - EurekaLog log file will be automatically appended to crash report:

 

 

EurekaLog log file inside EurekaLog's crash report

Double-click log file to view in viewer tool

 

Additionally, you may make a local copy (in other words, copy the file to your project) of TMSLoggingEurekaLogOutputHandler unit if you want to make modifications.

 

This approach is recommended over the alternative (see below), because it sends log in a formalized format, allowing for client-side manipulations in viewer tool.

 

 

TMS Logging to EurekaLog (alternative)

You may attach TMS Logging output as file directly (without converting to EurekaLog's logging).

 

Note: TMS Logging only provide saving to text formats (text, HTML, CSV). That is why we recommend to use above mentioned method instead (when possible).

 

You can attach the log file from TMS Logging with the following code example:

 

Important Note: example below will add a new file with log output from TMS Logging. The new file will be added inside EurekaLog's bug report that is being send to developers. In other words, you have to set up sending to receive this file. The local EurekaLog's report do not store any additional files. If you wish to capture .elp file locally for testing purposes - see this example.

 

uses

  VCL.TMSLogging,  // for TMS Logging routines
  // You can also use TMSLoggingHTMLOutputHandler
  // Please, refer to TMS Logging documentation 
  TMSLoggingTextOutputHandler,
  EException,      // for TEurekaExceptionInfo

  ESysInfo,        // for GetFolderTemp
  EEvents;         // for RegisterEventZippedFilesRequest
 
var
  // File name for TMS log file
  GTMSLogFileName: String;
 
// Initialize TMS Logging to save log to text file
// This is just an example
// You may replace/customize it
// Please, refer to TMS Logging documentation
procedure InitTMSLogging;
begin
  GTMSLogFileName := GetFolderTemp +
    ChangeFileExt(ExtractFileName(ParamStr(0)), '.txt'); 

 
  TMSLogger.RegisterOutputHandlerClass(TTMSLoggerTextOutputHandler, [GTMSLogFileName]);
end;
 
// Will be called when EurekaLog wants to 
// add additional files to packed bug report file (.elp)
procedure PackLogFile(const ACustom: Pointer; 
  AExceptionInfo: TEurekaExceptionInfo; 
  const ATempFolder: String
  AAttachedFiles: TStrings; 
  var ACallNextHandler: Boolean);
var
  LFileName: String;
begin
  // Get a temporary filename 
  LFileName := ATempFolder + ExtractFileName(GTMSLogFileName);
 
  // Copy the log file 
  CopyFile(PChar(GTMSLogFileName), PChar(LFileName), False);
 
  // Pack the file to EurekaLog's crash report 
  AAttachedFiles.Add(LFileName);
end;
 
initialization
  // Initialize TMS Logging to save log to text file
  InitTMSLogging;
 
  // Ask EurekaLog to add more files to .elp reports
  RegisterEventZippedFilesRequest(nil, PackLogFile);
end.

 

When you receive crash report from EurekaLog - the TMS Logging log will be shown as file attach:

 

 

TMS Logging log file inside EurekaLog's crash report

Double-click log file to view in your default assigned application (text editor)

 

 

EurekaLog to TMS Logging

Alternatively, you may want to set up a reverse integration. E.g. you may want to have EurekaLog's crash information inside your TMS Logging log files. Use example below:

 

uses

  VCL.TMSLogging,  // for TMS Logging routines

  EException,      // for TEurekaExceptionInfo

  EEvents;         // for RegisterEventExceptionNotify
 

// Tell EurekaLog to log crash info with TMS Logging
procedure LogExceptionToTMS(const ACustom: Pointer;
  AExceptionInfo: TEurekaExceptionInfo;
  var AHandle: Boolean;
  var ACallNextHandler: Boolean);
begin
  // Log exception 
  TMSLogger.Error(Format('[%s] %s',
    [AExceptionInfo.ExceptionClass,

     AExceptionInfo.ExceptionMessage]));
 
  // Log exception's call stack
  TMSLogger.Info(AExceptionInfo.CallStack.ToString);
 
  // You may also log other properties of AExceptionInfo
  // Or you can use routines from ESysInfo to log process and environment info
  // Of you can use BuildBugReport function to compose bug report text
end;
 
initialization

  // Tell EurekaLog to log crash info with TMS Logging
  RegisterEventExceptionNotify(nil, LogExceptionToTMS);
end.

 

 

See also:




Send feedback... Build date: 2024-09-30
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/logging_tms.php