Using CleanroomLogger for Better Logging in iOS Development

Using CleanroomLogger for Better Logging in iOS Development

CleanroomLogger is a well known logging API that is fully supported by Bugfender. This Swift compatible logging platform is popular for being lightweight and high performer. The main platform is compatible with Swift 2.2 and it needs Xcode 7.3 or higher version to compile projects. However, there are two more variants of CleanroomLogger that are specifically built to support later versions of Swift and Xcode.

One variant is compatible with Swift 2.3 and needs Xcode 8.0 to compile the projects while the other variant needs Swift 3.0 and Xcode 8.0 to compile the projects.

Why CleanroomLogger?

Developers must know why they should use CleanroomLogger so they can use this platform at its full potential. CleanroomLogger provides many advanced features which are not available in NSLog. Let’s talk about them in details.

  • In CleanroomLogger, every log is marked with a special tag called “log severity”. This tag defines the importance of each log. The process of defining the importance of these errors helps developers and testers remove errors with low priority and focus on high priority errors.
  • The platform is designed to use Swift short circuiting feature to prevent usage of inactive log channels. This approach makes the production code faster as all of the unnecessary parts would be totally ignored.
  • NSLog could work in many situations but it is not effective enough to pinpoint the exact source of a bug. On the other hand, CleanroomLogger makes it easier for programmers to find the exact line of code that is the root cause. The platform produces log file containing the exact line causing the error.
  • As compared to NSLog, CleanroomLogger uses calling thread efficiently and after receiving the request, the task is handed over in a background queue so the calling thread can get back to work as soon as possible. On the other hand, NSLog keeps the calling thread busy that leads to lower frame rate.
  • CleanroomLogger comes with built in “trace” feature that allows developers to track down the exact execution path their code is taking. Understanding the path might help in tracking down the line of code that is causing the error.
  • Unlike many other logging platforms that do not allow developers to have full control over the logging process throughout the app lifecycle, CleanroomLogger allows the programmer to set the logging polices as early as possible and those policies remain the same for other modules. For example, embedded frameworks and libraries would be forced to comply with those logging policies.
  • CleanroomLogger is highly configurable and developers can modify its behavior according to their requirements. Developers can use the default configuration as well as their own configurations.
  • One of the best things about CleanroomLogger is its extensibility. Developers can define custom implementations of different functions that could be used during the logging process.

What Are 1000 Apps Doing to Reduce Their Bugs to Zero?

Down to Zero is a practical guide to solving bugs. Our team has been developing mobile apps for over a decade and we'd like to share some tips we've picked up along the way.

Get the Ebook for Free

Down to Zero Ebook

CleanroomLogger is part of The Cleanroom Project that has many tools running under it. The project started as a legacy free Swift based project and now they have developed many tools for iOS, tvOS, macOS and watchOS. Some of their popular open source projects are CleanroomLogger, Cleanroom App Settings, Cleanroom ASL, Cleanroom Bridging, Cleanroom Concurrency, Cleanroom Text, Cleanroom Date Time and Cleanroom Data Transactions.

Getting Started With CleanroomLogger

The manual integration of CleanroomLogger refers to embedding the code into your iOS development project on Xcode. The entire process is explained in details here. By embedding the code with your project, it would automatically ensure the CleanroomLogger platform is built with the same configuration you are using on your project. This would help you avoid the frustration of checking different settings for different frameworks. The process of manual integration of CleanroomLogger with your Xcode project consists of five steps.

  1. First you need to download the source of CleanroomLogger into your project on Xcode.
  2. The next step is to embed CleanroomLogger code into your project.
  3. Build CleanroomLogger framework.
  4. Add CleanroomLogger framework in your app.
  5. Fix Xcode references.

As mentioned above, Bugfender fully support CleanroomLogger and both platforms could be used to effectively logging any abnormal behavior of the apps during iOS development and testing phase. Unlike many other crash reporting tools, Bugfender focuses on anomalies as well as total failure. As not all bugs lead to crash and total failure, it is essential to spotlight all types of abnormal behavioral patterns to ensure the app meets all quality standards.

For example, some bugs lead to significant reduction in the overall performance of the app; some cause stability issues while some bugs might lead to security vulnerabilities. Using CleanroomLogger and Bugfender allows developers to developer highly functional, stable and quality apps so they can compete with already established alternatives. Another benefit of using remote testing platforms like Bugfender is their ability to overcome the issue of fragmentation.

Device fragmentation is a real challenge nowadays and not only Android developers but iOS developers also suffer because there are many device models, platform versions and their permutations. In some cases, emulators could provide an effective solution but emulators cannot possibly mimic a real device. Remote testing tools ensure the developer or tester gets his hands on all the relevant logs whether the intended device is in his hands or located thousands of miles away.

Interestingly, developers and testers can control what devices should be monitored and logged so they can focus on bugs which appear on particular device models. It is almost impossible to reproduce a bug in controlled environment and that’s why developers and testers highly rely on logs collected from real devices. With the help of Bugfender and CleanroomLogger they can collect logs from devices where the error happens and analyze those bugs to find the root cause of the issue.

as_sk_telecom Created with Sketch. as_websummit Created with Sketch. as_menshealth Created with Sketch. as_taxify Created with Sketch. as_intel Created with Sketch. as_slack Created with Sketch. as_vorwerk Created with Sketch.

Already Trusted by Thousands

Bugfender is the best remote logger for mobile apps.

Get Started for Free, No Credit Card Required