Skip to content

Example_SimplestLog

Juan Antonio Castillo edited this page Mar 8, 2022 · 3 revisions

Example: Simplest log

This is an example on how easy is to to start adding log entries to your program

Code

uses
  ujachLogMgr, ujachLogAuto;

{$R *.dfm}

procedure TmyForm.ProcessData(InputFileName: string);
var 
  I: Integer;
begin
  jachLog.LogInfo('Data processing start, FileName: %s', [InputFileName]);
  try
    jachLog.LogInfo('Opening file...');
    OpenDataFile(InputFileName);
    jachLog.LogInfo('Processing %d records on file...', [FDataFile.RecordCount]);
    for I := 0 to FDataFile.RecordCount - 1 do
      ProcessDataRecord(I);
    jachLog.LogInfo('Closing file...');
    CloseDataFile();
    jachLog.LogInfo('Sending notifications...');
    SendNotifications;
    jachLog.LogInfo('Data processing finished succesfully');
  except
    on E:Exception do
    begin
      jachLog.LogError('Data processing finished with Error', E);
      raise;
    end;
  end;
end;