Majid Jabrayilov, an independent iOS developer, recently published a series of legends emphasizing the importance of logging for analyzing difficult errors to detect in a researcher as well as a better understanding of user behavior in the application. While using the Xcode error to test an iOS application is a smart way to make sure it is free of bugs, there are times when this is not a coincidence, according to Jabrayilov.
For example, [a bug] can occur only after a few days of using the app. In this case, running an application in an analog machine and testing a feature is not understandable. We need to understand what the user has done in the application and how it responds to user actions in this situation. In his piece, Jabrayilov describes a process that brings Apple Integration System to make it easier as it goes on to build a better logging system into an iOS application.
The cornerstone of this method is the os.Logger class, which extends all entries to the hardware system store under a given system and category. Logger provides several levels of logging, including trail, observation, warning, and special. Entries are available through Console.app on your Mac. To make all incoming information easily readable in Console.app, Jabrayilov said it was easy to use the existing OSLogInterpolation policies starting iOS 14. That includes options to control alignment, visibility, format , and so on.
An interesting feature of Apple’s Integrated System is that it makes it easy to export log information from a single user device, which can become life-saving in case a virus only shows up on the site and is not corrected during testing. For this purpose, it defines a custom OSLogStore that stands for filtering all log entries that meet specific requirements, including entry type, date, and so on. As Jabrayilov points out, OSLogStore can be easily integrated into its application to allow the user to export entries by pressing a button and sharing them selectively with the developer.
Overall, Jabrayilov describes a simple process to integrate logging into any iOS application. If you are interested, do not miss the original stuff, which includes sample code to illustrate all these ideas in details.