Using logs

When you buy the Shell Ace library, it becomes possible to log the calls of all interface methods implemented by the shell extension. It is possible to enable logging with the help of the corresponding directive in the file included in Shell Ace.

Using CodeSite

CodeSite is a professional real-time logging service from the Raize Software company. The Express edition of this service is included in Delphi starting from version XE. It can be purchased separately for earlier Delphi versions.

To enable logging with CodeSite, you should add the {$DEFINE USE_CODESITE} string to the file and recompile your extension. When the system uses your extension and calls any method, the CodeSite Live Viewer window will show a detailed log with all the values of input and output parameters and the method result in real time:

CodeSite Live Viewer window

Using text logs

It is impossible to use CodeSite in some cases. For example, the Browser helper object in the modern versions of Internet Explorer can run in the Enhanced Protected Mode. In this mode, the BHO has lower privileges and cannot correctly work with the CodeSite service.

It is possible to use text files for logging in such cases. To enable this mode, you should do the following:

  1. Add the {$DEFINE USE_FILELOGS} string to the file.
  2. Add a string of the following type to the Initialization section of any module: LogStream := TFileStream.Create(LogFileName, fmCreate), where LogFileName is the name of the text file logs will be saved to. The created object will be automatically deleted when the library is closed. It is recommended that the file should be located at %USER PROFILE%\AppData\LocalLow since it is guaranteed that it is possible both to write to that folder and to create subfolders in it. At the same time, the name of the file should be unique because several instances of the extension can be loaded at the same time. Sample code:
  3. Some code will be here soon

  4. Recompile your extension.

When the system uses your extension after that and calls any method, a detailed log with all the values of input and output parameters and the result of the method will be added to the specified file.

Do not forget to disable the {$DEFINE USE_CODESITE} and {$DEFINE USE_FILELOGS} directives while compiling the final build.

See also: