IdLogEvent.pas 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 10235: IdLogEvent.pas
  11. {
  12. { Rev 1.0 2002.11.12 10:44:18 PM czhower
  13. }
  14. unit IdLogEvent;
  15. interface
  16. uses
  17. Classes,
  18. IdLogBase;
  19. type
  20. TLogItemStatusEvent = procedure(ASender: TComponent; const AText: string) of object;
  21. TLogItemDataEvent = procedure(ASender: TComponent; const AText: string; const AData: string)
  22. of object;
  23. TIdLogEvent = class(TIdLogBase)
  24. protected
  25. FOnReceived: TLogItemDataEvent;
  26. FOnSent: TLogItemDataEvent;
  27. FOnStatus: TLogItemStatusEvent;
  28. //
  29. procedure LogStatus(const AText: string); override;
  30. procedure LogReceivedData(const AText: string; const AData: string); override;
  31. procedure LogSentData(const AText: string; const AData: string); override;
  32. public
  33. published
  34. property OnReceived: TLogItemDataEvent read FOnReceived write FOnReceived;
  35. property OnSent: TLogItemDataEvent read FOnSent write FOnSent;
  36. property OnStatus: TLogItemStatusEvent read FOnStatus write FOnStatus;
  37. end;
  38. implementation
  39. { TIdLogEvent }
  40. {procedure TIdLogEvent.Log(AText: string);
  41. var
  42. s: string;
  43. begin
  44. if assigned(OnLogItem) then begin
  45. OnLogItem(Self, AText);
  46. end;
  47. case Target of
  48. ltFile: begin
  49. FFileStream.WriteBuffer(PChar(AText)^, Length(AText));
  50. s := EOL;
  51. FFileStream.WriteBuffer(PChar(s)^, Length(s));
  52. end;
  53. ltDebugOutput: begin
  54. DebugOutput(AText + EOL);
  55. end;
  56. end;
  57. end;}
  58. { TIdLogEvent }
  59. procedure TIdLogEvent.LogReceivedData(const AText, AData: string);
  60. begin
  61. if Assigned(OnReceived) then begin
  62. OnReceived(Self, AText, AData);
  63. end;
  64. end;
  65. procedure TIdLogEvent.LogSentData(const AText, AData: string);
  66. begin
  67. if Assigned(OnSent) then begin
  68. OnSent(Self, AText, AData);
  69. end;
  70. end;
  71. procedure TIdLogEvent.LogStatus(const AText: string);
  72. begin
  73. if Assigned(OnStatus) then begin
  74. OnStatus(Self, AText);
  75. end;
  76. end;
  77. end.