当前位置:网站首页>Swift -- save print log to sandbox
Swift -- save print log to sandbox
2022-06-22 16:08:00 【Infinite determination】
Recently, I often encountered the problem of jamming during project testing , Integrated bug The collector cannot collect the problem , There is no way to locate the problem , Write a method to print log collection , Save it in a sandbox , So that when the tester finds out that the card is stuck , We can locate the problem according to the printed log , The code is as follows :
private func redirectNSlogToDocumentFolder() {
let filePath: String = NSHomeDirectory () + "/Documents/PrintfInfo.log"
let defaultManager = FileManager.default
try? defaultManager.removeItem(atPath: filePath)
freopen(filePath.cString(using: String.Encoding.ascii), "a+", stdout)
freopen(filePath.cString(using: String.Encoding.ascii), "a+", stderr)
}
The call is simple , Directly in willFinishLaunchingWithOptions Just call :
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
let device = UIDevice.current
if device.model == "iPhone" {
// Real machine
self.redirectNSlogToDocumentFolder()
}
return true
}
Apple's default App File visibility is turned off , We need to be in plist You can only view the data in the sandbox with the restart permission in :Application supports iTunes file sharing The value of the set YES, That's it
边栏推荐
- 中信建投证券是跟启牛学堂存在什么关系?开证券账户安全吗
- Navicat premium connecting to Oracle database (Graphic tutorial)
- 微信小程序头像挂件制作
- 【山大会议】项目初始化
- [single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want
- 阿里云中间件的开源往事
- vector的模拟实现
- odoo部署到服务器并配置为服务
- 【单片机】【让蜂鸣器发声】认识蜂鸣器,让蜂鸣器发出你想要的声音
- Trust level of discover
猜你喜欢
随机推荐
静态断言 static_assert
【山大会议】软件性能优化及bug修复
HMS core news industry solution: let technology add humanistic temperature
[Shanda conference] establishment of webrtc tools for multi person video call
[Shanda conference] definitions of some basic tools
Rosbag使用命令
【山大会议】使用TypeScript为项目进行重构
Swift -- 保存打印日志到沙盒
Differences between Oracle client and server
Oracle客户端和服务端的区别
84.(cesium篇)cesium模型在地形上运动
Scala language learning-06-differences between name passing parameters, value passing parameters and function passing parameters
打新债安全性有多高
Mysql触发器
ironSource Luna 推出苹果搜索广告限时优惠,注册即享3个月免费服务
ArcGIS JS之 4.23之IIS本地部署与问题解决
推進兼容適配,使能協同發展 GBase 5月適配速遞
The MIHA tour club in June is hot! 500+ posts, more than HC, just this summer (with internal promotion method)
Scala language learning-05-a comparison of the efficiency of recursion and tail recursion
UK considers listing arm in London based on national security









