Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OutputDebugString() with Delphi for MacOS

Is there an NSLog declaration in the Delphi OSX units. I failed to find a substitude for OutputDebugString in a Firemonkey application.

The final solution looks like this:

/// <remarks>
/// Output debug string. Output debug string can be seen in Delphi
/// View|Debug Windows|Event Log or with 3-rd party programs such as
/// dbgview.exe from SysInternals (www.sysinternals.com)
/// </remarks>
procedure ODS(const Text: string);
begin
  {$IFDEF MACOS}
  // http://stackoverflow.com/questions/12405447/outputdebugstring-with-delphi-for-macosunit unt_Debug;
  Log.d(Text);
  {$ENDIF}
  {$IFDEF LINUX}
  __write(stderr, AText, Length(AText));
  __write(stderr, EOL, Length(EOL));
  {$ENDIF}
  {$IFDEF MSWINDOWS}
  OutputDebugString(PWideChar(Text));
  {$ENDIF}
end;
like image 742
Gad D Lord Avatar asked Sep 13 '12 11:09

Gad D Lord


People also ask

How to view the outputdebugstring of a Delphi application?

Anyway, the natural way to view the OutputDebugString output for a Delphi application is to use the Delphi IDE and the Event Log Window. Show activity on this post.

What is Delphi IDE?

Delphi Delphi® is the world's most advanced integrated IDE for rapidly developing native high-performance multi-platform applications using powerful visual design tools and features developers love.

What does outputdebugstring do when there is no debugger?

For details on how the filter mask controls what the system debugger displays, see the DbgPrint function in the Windows Driver Kit (WDK) on MSDN.) If the application has no debugger and the system debugger is not active, OutputDebugString does nothing. Prior to Windows Vista: The system debugger does not filter content.

How do I output a Debug log?

Another way is to output log messages, for example to a text file. You can also use the OutputDebugString function. An advantage of this approach is that it impacts your application as little as possible. You don't have to care about file handling. Just call a function.


1 Answers

In Firemonkey, the portable way to display a message in the Event Log is Log.d:

    uses FMX.Types;

    ...

    Log.d('debugging');

I think it is available from XE3 onwards.

like image 189
JRL Avatar answered Oct 03 '22 00:10

JRL