使用Delphi for MacOS的OutputDebugString()

时间:2012-09-13 11:41:58

标签: delphi delphi-xe2 nslog firemonkey outputdebugstring

Delphi OSX单元中是否有NSLog声明。我没能在Firemonkey应用程序中找到OutputDebugString的替代。

最终解决方案如下:

/// <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;

1 个答案:

答案 0 :(得分:5)

在Firemonkey中,在事件日志中显示消息的便携方式是Log.d

    uses FMX.Types;

    ...

    Log.d('debugging');

我认为可以从XE3开始提供。