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;
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With