Inherits from NSObject
Declared in OCLogger.h

Overview

Contains OCLogger methods that manage client side logs.

Class Methods

getCapture

This method gets the current setting for determining if log data should be saved persistently.

+ (BOOL)getCapture

Return Value

Boolean flag indicating whether the log data must be saved persistently

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

getFilters

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

+ (NSDictionary *)getFilters

Return Value

Dictionary defining the logging filters

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

getInstanceWithPackage:

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

+ (OCLogger *)getInstanceWithPackage:(NSString *)package

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

OCLogger instance used to create subsequent log calls

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

getLevel

This method gets the current OCLogger_LEVEL and returns OCLogger_LEVEL.

+ (OCLogType)getLevel

Return Value

OCLogType for the current log level

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

getMaxFileSize

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

+ (int)getMaxFileSize

Return Value

int indicating the maximum file size threshold

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

getShowLogsInConsole

This method gets the current setting for determining if log data should be displayed on log console or not

+ (BOOL)getShowLogsInConsole

Return Value

Boolean flag indicating whether the log data must be displayed on log console

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

isUnCaughtExceptionDetected

This method indicates that an uncaught exception was detected. The indicator is cleared on successful send.

+ (BOOL)isUnCaughtExceptionDetected

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

logNetworkData:

This method helps in sending the Network Logs to the server

+ (void)logNetworkData:(NSString *)message

Declared In

OCLogger.h

send

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

+ (void)send

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

sendIfUnCaughtExceptionDetected

This method sends the log file when the log buffer exists, the log is not empty, and an uncaught exception occurred.

+ (void)sendIfUnCaughtExceptionDetected

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

sendWithDelegate:

This method is the same as send, with the addition of a delegate that is notified when the send request succeeds or fails.

+ (void)sendWithDelegate:(id<WLDelegate>)userSendLogsDelegate

Parameters

userSendLogsDelegate

WLDelegate that handles the result of the send request with the onSuccess and onFailure methods.

Availability

IBM MobileFirst Platform V7.0.0

See Also

Declared In

OCLogger.h

setAutoSendLogs:

Global setting: Turns Auto Log Send on or off

+ (void)setAutoSendLogs:(BOOL)flag

Parameters

Boolean

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.

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

setAutoSendLogs:interval:

Global setting: Turns Auto Log Send on or off

+ (void)setAutoSendLogs:(BOOL)flag interval:(int)seconds

Parameters

Boolean

Flag determines whether or not logs are automatically forwarded to the server on each successful resource request.

interval

seconds to change the default interval to trigger log send

Availability

IBM Worklight V8.0

Declared In

OCLogger.h

setCapture:

Global setting: turn persisting of the log data that is passed to the log methods of this class, on or off.

+ (void)setCapture:(BOOL)flag

Parameters

Boolean

flag to indicate whether the log data must be saved persistently

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

setFilters:

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.

+ (void)setFilters:(NSDictionary *)filters

Parameters

Dictionary

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

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

setLevel:

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

+ (void)setLevel:(OCLogType)level

Parameters

level

OCLogType The valid values of this input parameter are OCLogger_DEBUG, OCLogger_ERROR, OCLogger_INFO, OCLogger_LOG, and OCLogger_WARN.

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

setMaxFileSize:

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.

+ (void)setMaxFileSize:(int)bytes

Parameters

int

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

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

setShowLogsInConsole:

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

+ (void)setShowLogsInConsole:(BOOL)flag

Parameters

Boolean

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

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

updateConfigFromServer

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.

+ (void)updateConfigFromServer

Declared In

OCLogger.h

Instance Methods

debug:

This method logs at DEBUG level.

- (void)debug:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

error:

This method logs at ERROR level.

- (void)error:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

fatal:

This method logs at FATAL level.

- (void)fatal:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

info:

This method logs at INFO level.

- (void)info:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

log:

This method logs at LOG level.

- (void)log:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

logWithLevel:message:args:userInfo:

Logs a message at a specific OCLogType 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.

- (void)logWithLevel:(OCLogType)level message:(NSString *)message args:(va_list)arguments userInfo:(NSDictionary *)userInfo

Parameters

level

OCLogType log level used

message

String Message logged

arguments

va_list Arguments used for string replacements in the message parameter

userInfo

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

Availability

IBM Worklight V6.4.0

Declared In

OCLogger.h

metadata:debug:

This method logs at DEBUG level.

- (void)metadata:(NSDictionary *)metadata debug:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

metadata:enter:

This method prints the function Entry

- (void)metadata:(NSDictionary *)metadata enter:(NSString *)text, ...

Declared In

OCLogger.h

metadata:error:

This method logs at ERROR level.

- (void)metadata:(NSDictionary *)metadata error:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

metadata:exit:

This method prints the function Exit

- (void)metadata:(NSDictionary *)metadata exit:(NSString *)text, ...

Declared In

OCLogger.h

metadata:fatal:

This method logs at FATAL level.

- (void)metadata:(NSDictionary *)metadata fatal:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

metadata:info:

This method logs at INFO level.

- (void)metadata:(NSDictionary *)metadata info:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

metadata:log:

This method logs at LOG level.

- (void)metadata:(NSDictionary *)metadata log:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

metadata:trace:

This method logs at TRACE level.

- (void)metadata:(NSDictionary *)metadata trace:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

metadata:warn:

This method logs at WARN level.

- (void)metadata:(NSDictionary *)metadata warn:(NSString *)text, ...

Parameters

metadata

Dictionary containing metadata to append to the log output

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

trace:

This method logs at TRACE level.

- (void)trace:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h

warn:

This method logs at WARN level.

- (void)warn:(NSString *)text, ...

Parameters

String

message to be logged

Availability

IBM Worklight V6.2.0

Declared In

OCLogger.h