unit Logger;
interface
uses SysUtils, Forms;
const
DEBUG_MODE = True;
procedure Debug(FormName, msg: String);
implementation
procedure Debug(FormName, msg: String);
var
myFile : TextFile;
Path : String;
FileHandle: Integer;
myDate : TDateTime;
// Stream : FileStream;
begin
myDate := Now;
Path := ExtractFilePath( Application.ExeName ) + 'application.log';
if not FileExists(Path) then
begin
FileHandle := FileCreate(Path);
FileClose(FileHandle);
end;
if DEBUG_MODE then begin
// Try to open the Test.txt file for writing to
AssignFile(myFile, path ) ;
ReWrite(myFile);
// Append(myFile);
// Write a couple of well known words to this file
WriteLn(myFile, FormatDateTime('c', myDate) + ' [' + FormName + '] ' + msg);
// Close the file
CloseFile(myFile);
end;
end;
end.
You may find if useful somehow... :p
No comments:
Post a Comment