加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

使用Delphi for MacOS的OutputDebugString()

发布时间:2020-12-15 09:28:19 所属栏目:大数据 来源:网络整理
导读: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 pa
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}
  // https://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;

解决方法

在Firemonkey中,在事件日志中显示消息的可移植方式是 Log.d:

uses FMX.Types;

    ...

    Log.d('debugging');

我认为它从XE3开始提供.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读