OCLoggerSwift

public class OCLoggerSwift

Provides methods for Logging

  • This method gets or creates an instance of this logger. If an instance exists for the package parameter, that instance is returned.

    Declaration

    Swift

    public static func getInstanceWithPackage(package: String!) -> OCLoggerSwift

    Parameters

    package

    String denoting package or tag that must be printed with log messages. The value is passed through to NSLog and recorded when log capture is enabled.

    Return Value

    OCLoggerSwift instance used to create subsequent log calls

  • This method sends the log file when the log buffer exists and is not empty.

    Declaration

    Swift

    public static func send()
  • This method sends the log file when the log buffer exists, the log is not empty, and an uncaught exception occurred.

    Declaration

    Swift

    public static func sendIfUnCaughtExceptionDetected()
  • This method gets the current setting for determining if log data should be saved persistently.

    Declaration

    Swift

    public static func getCapture() -> Bool
  • Global setting: turn persisting of the log data that is passed to the log methods of this class, on or off.

    Declaration

    Swift

    public static func setCapture(flag: Bool)

    Parameters

    flag

    Flag to indicate whether the log data must be saved persistently

  • Global setting: turn display of logs on log console , on or off.

    Declaration

    Swift

    public static func setShowLogsInConsole(flag: Bool)

    Parameters

    flag

    flag to indicate whether the log data must be displayed in log console or not

  • This method will retrieve the filters that are used to determine which log messages are persisted.

    Declaration

    Swift

    public static func getFilters() -> [AnyHashable : Any]!

    Return Value

    Dictionary defining the logging filters

  • This method sets the filters that are used to determine which log messages are persisted. Each key defines a package name and each value defines a logging level.

    Declaration

    Swift

    public static func setFilters(filters: [AnyHashable : Any]!)

    Parameters

    filters

    Dictionary containing the package name and logging level key value pairs that are used to filter persisted logs

  • This method gets the current setting for the maximum file size threshold.

    Declaration

    Swift

    public static func getMaxFileSize() -> Int32

    Return Value

    Int indicating the maximum file size threshold

  • This method sets the maximum size of the local log file. When the maximum file size is reached, no more data is appended. This file is sent to a server.

    Declaration

    Swift

    public static func setMaxFileSize(bytes: Int32)

    Parameters

    bytes

    Int defining the maximum size of the file in bytes, the minimum is 10,000 bytes.

  • This method gets the current OCLogger_LEVEL and returns OCLogger_LEVEL.

    Declaration

    Swift

    public static func getLevel() -> OCLogTypeSwift

    Return Value

    OCLogger_LEVEL

  • This method sets the level from which log messages must be saved and printed. For example, passing OCLogTypeSwift.OCLogger_INFO logs INFO.

    Declaration

    Swift

    public static func setLevel(level: OCLogTypeSwift)

    Parameters

    level

    OCLogTypeSwift.OCLogger_INFO or OCLogTypeSwift.OCLogger_WARN etc

  • Global setting: Turns Auto Log Send on or off

    Declaration

    Swift

    public static func setAutoSendLogs(flag: Bool)

    Parameters

    flag

    Flag determines whether or not logs are automatically forwarded to the server on each successful resource request, if no logging has occurred for 60 seconds.

  • Get and apply the configuration from the IBM MobileFirst Platform Server. The configuration comes from the use of the Config Profiles tab in the IBM MobileFirst Platform administrative console. Note that this configuration will override the current configuration set on the device.

    Declaration

    Swift

    public static func updateConfigFromServer()
  • This method indicates that an uncaught exception was detected. The indicator is cleared on successful send.

    Declaration

    Swift

    public static func isUnCaughtExceptionDetected() -> Bool

    Return Value

    Boolean value

  • Logs a message at a specific OCLogTypeSwift log level with string replacement using arguments passed. This method also attaches a dictionary of user information to the log message that is available when logs are persisted and sent to the Analytics Server as custom analytics.

    Declaration

    Swift

    public func logWithLevel(withLevel: OCLogTypeSwift, message: String!, args: CVaListPointer, userInfo: [AnyHashable : Any])

    Parameters

    level

    OCLogTypeSwift log level used

    message

    String message to be logged

    args

    CVaListPointer Arguments used for string replacements in the message parameter

    userInfo

    Dictionary Additional data appended to the log message and sent to the Analytics Server as custom analytics data