【问题标题】:How to suppress Alamofire output to debug console in Xcode如何在 Xcode 中抑制 Alamofire 输出以调试控制台
【发布时间】:2021-10-02 11:56:40
【问题描述】:

最简单的 Alamofire 示例。 main.swift:

import Alamofire
import Foundation

AF.request("https://httpbin.org/get").response { response in
    // debugPrint(response)
}

RunLoop.current.run()

写入调试控制台输出,例如:

2021-10-02 14:45:28.198648+0300 AlamofireExp1[4891:191952] [logging] volume does not support data protection, stripping SQLITE_OPEN_FILEPROTECTION_* flags
2021-10-02 14:45:28.199070+0300 AlamofireExp1[4891:191952] [logging] volume does not support data protection, stripping SQLITE_OPEN_FILEPROTECTION_* flags
2021-10-02 14:45:28.626982+0300 AlamofireExp1[4891:191952] [connection] nw_endpoint_handler_set_adaptive_read_handler [C1.1 54.159.86.231:443 ready socket-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for read_timeout failed
2021-10-02 14:45:28.627089+0300 AlamofireExp1[4891:191952] [connection] nw_endpoint_handler_set_adaptive_write_handler [C1.1 54.159.86.231:443 ready socket-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for write_timeout failed
2021-10-02 14:45:28.756444+0300 AlamofireExp1[4891:191941] [logging] volume does not support data protection, stripping SQLITE_OPEN_FILEPROTECTION_* flags
2021-10-02 14:45:28.756749+0300 AlamofireExp1[4891:191941] [logging] volume does not support data protection, stripping SQLITE_OPEN_FILEPROTECTION_* flags

问题:如何抑制这个垃圾(对我而言)输出到调试控制台?

【问题讨论】:

    标签: alamofire


    【解决方案1】:

    这不是 Alamofire 日志记录,这是来自底层操作系统的日志记录。不幸的是,没有很好的方法来禁用它。从技术上讲,您可以将OS_ACTIVITY_MODE 环境变量设置为disable 以进行构建,但这会禁用所有OS 模块功能,包括您自己的OSLogs 和路标以及其他功能,因此不推荐。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-04
      相关资源
      最近更新 更多