Logging changes in WordPress for iOS

One of the things we’ve added to WordPress for iOSiOS The operating system used on iPhones and iPads. in the upcoming 3.8.4 release is a better way to handle feedback from users of the app.  We’ve added CocoaLumberjack to the project to replace our previous method of using FileLogger and three macros throughout the project to log.  There were some limitations with that approach, primarily being no way to easily set the verboseness of the logging.  Turning on “extra debug” involved setting a NSUserDefaults flag that was checked (inconsistently) across the app.  CocoaLumberjack supports multiple (and custom) logging levels to allow for us to turn up and down the amount of logging in the app.

The three logging macros we defined (WPLog, WPLogMethod, WPLogMethodParam) are still available but they have been moved to WordPress_Prefix.pch.  Instead of using these three methods use one of the pre-defined CocoaLumberjack logging macros:


In WordPress_Prefix.pch we define the default logging level variable ddLogLevel. In WordPressAppDelegate.m the value is defined as LOG_LEVEL_INFO. What this means is any logging that is under INFO (Verbose) will be excluded from the log file and console. Turning on “extra debug” will flip that logging level to VERBOSE – this is done in both the app delegate and the settings screen during runtime.

Log files are now kept beyond a single crash as well. CocoaLumberjack will keep up to seven log files, rolling a log file over after the calendar day has passed. Users can explore the contents of the logs through Settings -> Support.