FireMonkey. Логирование ошибок в файл
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
program Project1; uses System.StartUpCopy, FMX.Forms, System.IOUtils, System.SysUtils, Unit2 in 'Unit2.pas' {Form2}; type TAppErrors=class procedure ErrorLog(Sender:Tobject;E:Exception); end; {$R *.res} { TAppErrors } procedure TAppErrors.ErrorLog(Sender: Tobject; E: Exception); var s:string; begin s:=Format('%s'+#9+'%s',[DateTimeToStr(Now),E.Message]); TFile.AppendAllText('errors.log',s+#10#13); Application.ShowException(E); end; var AppError:TAppErrors; begin AppError:=TAppErrors.Create; Application.OnException:=AppError.ErrorLog; Application.Initialize; Application.CreateForm(TForm2, Form2); Application.Run; end. |