Recent

Author Topic: How to use the Event Log?  (Read 8051 times)

piola

  • Full Member
  • ***
  • Posts: 147
  • Lazarus 2.2, 64bit on Windows 8.1 x64
Re: How to use the Event Log?
« Reply #15 on: June 13, 2024, 12:10:02 pm »
In case others want to use this combination (Application.Log to the event log window), too: As a workaround, one can use:

Code: [Select]
uses
  {$ifdef mswindows}Windows,{$endif}
  Forms,
  SysUtils;

{$modeswitch typehelpers}

type TApplicationHelper = type helper for TApplication
  procedure Log (EventType: TEventType; const Msg: String);
  procedure Log (EventType: TEventType; const Fmt: String; const Args: array of const);
end;

procedure TApplicationHelper.Log (EventType: TEventType; const Msg: String);
  begin
    {$ifdef debug} // whatsoever
    {$ifdef mswindows}
    OutputDebugString (PAnsiChar(Msg));
    {$endif}
    {$endif}
  end;

procedure TApplicationHelper.Log (EventType: TEventType; const Fmt: String; const Args: array of const);
  begin
    Log (EventType, Format (Fmt, Args));
  end;

 

TinyPortal © 2005-2018