MobileMonitor

public class MobileMonitor

Allows an application to add monitor data that can be stored and transmitted once a user is online.    The MobileMonitor is a non-intrusive and non-blocking log collector that can be configured to be more or less aggressive with monitoring logs.  all items are processed in a serial queue on a background thread.  By default, the monitor will trace database events and report their status with a timestamp for debugging time critical operations.  It will also attempt to detect document conflicts  which can be a cause for concern for applications.    Additionally, applications can add their own monitoring and bundle it with the monitor items that are included by default.  This allows applications to dynamically collect logs when needed to help remotely route cause issues  without needed to send a new application to the device.    The monitor has been optimized to be non-intrusive to the running application, however users may still experience some lag if the monitor is set to aggressively collect, save and transmit logs.

  • Default instance for an application

    Declaration

    Swift

    public static let applicationMonitor = MobileMonitor(withConfig: ApplicationMonitorConfig())
  • Adds an information string to the monitor log. By default items logged as info are only sent on the next login when the user is online. To change this please see PredixMobilityConfiguration.clientMonitorSendsLogsContinuously property for more information.

    Declaration

    Swift

    public func addInfo(data: [String : Any])

    Parameters

    data

    JSON serializable dictonary

  • Writes monitor logs to disk immediately

    Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the monitor logs to what is on disk.

    Declaration

    Swift

    @objc public func synchronize()
  • Gathers and provides all of the monitor logs that have not been sent successfully sent to the given LogTransmitter.

    The LogTransmitter is responsible for sending the logs to their proper destination. Calling this method will pause other logs from being saved while the logs are being sent to the server.

    NOTES:

    • This method class the LogTransmitter on the callers thread, if you do not wish to block your thead when calling this method the LogTransmitter should do its operations in a background thread.
    • If a log is transmitted successfully then the locally saved logs are removed from disk and the saving of new logs is resumed. If the logs are not successfully transmitted than new logs are appended to the existing logs saved to disk.

    • monitorTransmitter: The LogTransmitter that you want to have transmit the monitor logs.

    Declaration

    Swift

    public func transmitMonitorData(_ monitorTransmitter: LogTransmitter)

    Parameters

    monitorTransmitter

    The LogTransmitter that you want to have transmit the monitor logs.

  • Adds an alert string to the monitor log.

    By default items logged as alert will be queued for transmit and if no new alerts come in within the PredixMobilityConfiguration.clientMonitorTransmitDelay time the monitor logs will be transmitted.

    Declaration

    Swift

    public func addAlert(_ message: String, data: [String : Any]?)

    Parameters

    message

    An alert message

    data

    Additonal alert data as a JSON serializable dictonary