Logger

  • A logging framework that can print messages to the console, store them locally on the device, and send them to the Mobile Analytics service. With each log message, additional information is gathered such as the file, function, and line where the log was created, as well as the severity of the message.

    Multiple Logger instances can be created with different names using logger(name:).

    When logging, choose the log method that matches the severity of the message. For example, use debug(message:) for fine-detail information and error(message:) for unintended failures. To limit which logs get printed to the console and stored on the device, set the logLevelFilter property.

    To enable logs to be stored locally on the device, set isLogStorageEnabled to true. Logs are added to the log file until the file size is greater than the maxLogStoreSize. At this point, the first half of the stored logs will be deleted to make room for new log data.

    To send logs to the Mobile Analytics service, use send(completionHandler:). When the log data is successfully uploaded, the logs will be deleted from local storage.

    Note

    The Logger class sets an uncaught exception handler to log application crashes. If you wish to set your own exception handler, do so before calling logger(name:), or the Logger exception handler will be overwritten.
    See more

    Declaration

    Swift

    public class Logger
  • The severity of the log message.

    When setting Logger.logLevelFilter, the LogLevels, ordered from most restrictive to least, are: none, analytics, fatal, error, warn, info, and debug.

    Note

    Set Logger.logLevelFilter to .none to prohibit logs from being recorded.
    See more

    Declaration

    Swift

    public enum LogLevel : Int