Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Log file on costumer computer


#1

Hi All,
I’m a Delphi developer. I use Delphi7. I’m currently evaluating SmartInspect. I will use mainly log files. I had configured correctly and manage to have the log files populated in my developing machine. But the executable running on the target machine does not create the log files nor generate any kind of errors. Do I need to deploy additional files? DLL’s or other ? I was under the impression that Smartinspect was compiled right in to the .EXE (I only deploy the .EXE to the final costumer).

Thanks in advance for any help
Joaquim


#2

Hello Joaquim,

It is correct that the SmartInspect library gets compiled into the .exe by default (you also have the option to use it as an external .bpl), so this shouldn’t cause the problem. No external libraries or applications are needed. If logging is configured correctly (i.e. setting Si.Enabled to True and setting the connections string to log to a file), then it’s likely that the SmartInspect library encounters a problem while trying to open the specified log file. For example, it’s likely to be a permission problem on the target machine (or maybe the target directory does not exist). In which directory do you try to log?

The reason why you do not see an error is that the library does not raise an exception but rather uses a special event to report exceptions in order to not change the exception behavior of your application. This event is called OnError can be used as follows:

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SiAuto, SmartInspect, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure OnError(ASender: TSmartInspect; AException: Exception);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Si.OnError := OnError;
  Si.Connections := 'file(filename="c:\log.sil")';
  Si.Enabled := True;
end;

procedure TForm1.OnError(ASender: TSmartInspect; AException: Exception);
begin
  ShowMessage(AException.Message);
end;

end.

More information about the error handling of the libraries can be found in the online help (press F1 in the Console) under “Working with SmartInspect | Library Error Handling”.