AwesomeLogs provide a simple, fast API for capturing log messages within your application. In addition to being output to the Xcode console, AwesomeLogs are automatically captured with bug reports.

There are several log levels provided by AwesomeLogs:

Level Objective-C Swift Behavior
Debug LIFELogDebug() life_log_debug() Captures debug-level messages. For most applications, this is a suitable replacement for NSLog().
Info LIFELogInfo() life_log_info() Info-level log messages can be used to capture information of increased relevance for troubleshooting errors.
Error LIFELogError() life_log_error() Error-level log messages should be used for unexpected errors in your code. Examples of this are JSON parse errors, database migration errors, etc.

Usage (Objective-C)

To automatically convert your project’s NSLog statements to LIFELogDebug statements, we’ll do the following:

  1. Add a prefix header to your project if it doesn’t already have one. If your project already has a prefix header (i.e. Projectname-Prefix.pch), skip to step 2.

    a. Add a new PCH file to your Xcode project: New file > Other > PCH file. Name this file ProjectName-Prefix.pch, replacing ‘ProjectName’ with your actual Xcode project name.

    Make sure to check your app target when adding this file.

    b. Select your project in the Xcode project navigator, and select your app target. Under the Build Settings tab, find the setting for Prefix Header, and set the value to the path of your newly added prefix header file.


    Tip: You can use build variables such as $(SRCROOT), $(PROJECT_DIR), $(PRODUCT_DIR), or $(PRODUCT_NAME) to get to the path of where you put the .pch in your project.

    c. In the same build settings view, set the value of Precompile Prefix Header to YES.

  2. Add the following lines of code to your prefix header:

    #define NSLog(frmt, ...) LIFELogDebug(frmt, ##__VA_ARGS__)
    #import <Buglife/LIFEAwesomeLogger.h>

That’s it! Your application logs will now be sent along with bug reports.

For info- and error-level logs, use the LIFELogInfo() and LIFELogError() macros.

Usage (Swift)

  1. Make a copy of AwesomeLogs.swift (from the Buglife-iOS GitHub repo), and add it to your project.
  2. Find all occurrences of NSLog() and print() in your Swift code, and replace them with life_log_debug().

That’s it! Your application logs will now be sent along with bug reports.

For info- and error-level logs, sue the life_log_info() and life_log_error() functions.