The library supports logging via its ISDMLogger interface and provides SDMLogger as an implementation of this interface.
The SDMConnectivity sets the User, Language and SUP/SAP NetWeaver Gateway URL fields. SDMLogger stores log entries timestamped, in milliseconds granularity of the time the log method called by the application/library component. It can also clean out log messages below a certain level, or clean out the log completely. A preliminary log rotation support is built in. At every log method call, a check runs and verifies whether the number of messages reaches 10000. If the number of messages is greater or equal to this threshold, a low priority background thread is started to clean out the oldest 200 log entries.
SDMLogger provides line-level location logging with the full class name of the logging class. Location detection is done by call stack evaluation. Therefore, SDMLogger provides location parameter setting for the logging class, where the class can set the location instead of using the detection facility. Log messages are stored only above the predefined logging level, which defaults to ERROR log level.
public void log(final int level, final String tag, final String msg, final Throwable tr, final String location)
Parameters:
level the log level msg The message you would like logged. tr An exception to log location The line-level location of the log source (full class name of the class) public static int d (String tag, String msg) public static int d (String tag, String msg, Throwable tr) public static int d (String tag, String msg, Throwable tr, String location) Sends a DEBUG log message and logs the exception. public static int e (String tag, String msg) public static int e (String tag, String msg, Throwable tr) public static int e (String tag, String msg, Throwable tr, String location) Sends an ERROR log message and logs the exception. public static int i (String tag, String msg) public static int i (String tag, String msg, Throwable tr) public static int i (String tag, String msg, Throwable tr, String location) Sends an INFO log message and logs the exception. public static int v (String tag, String msg) public static int v (String tag, String msg, Throwable tr) public static int v (String tag, String msg, Throwable tr, String location) Sends a VERBOSE log message and logs the exception. public static int w (String tag, Throwable tr) public static int w (String tag, String msg) public static int w (String tag, String msg, Throwable tr) public static int w (String tag, String msg, Throwable tr, String location) Sends a WARN log message and logs the exception. public static int wtf (String tag, Throwable tr) public static int wtf (String tag, String msg) public static int wtf (String tag, String msg, Throwable tr) public static int wtf (String tag, String msg, Throwable tr, String location) What a Terrible Failure: Reports a condition that should never happen. The error will always be logged at level ASSERT.
public void cleanUp(final int threshold) Deletes all log entries weaker than the ‘threshold’ priority. public void terminate() Completely clears the collected log data. public Vector<LogEntry> getLogElements(final int threshold) This method returns the log data, including all log data with level ‘threshold’ or above. public boolean logsToAndroid() public void logToAndroid(final boolean doIt) These methods get and set the property which controls sending the log output to the Android logging facility. public boolean logsFullLocation() public void logFullLocation(boolean logFullLocation) These methods get and set the property which if full location should be logged automatically based on the current stack trace. public synchronized String toString() Returns all log data – including the header – as String.
Operating System version: 11 Application name: MyApp Application version: 1.0.0 3rd-party products: - Hardware version: Galaxy Tab User name: DEMO Timezone: CET-DST Language: en Base URL: http://www.sap.com/gateway/or/whatever 2011-06-28 14:30:23.368 WARN SDMPreferences com.sap.mobile.lib.sdmconfiguration.SDMPreferences.getPreference(SDMPreferences.java:284) Deprecated method 'getPreference' has been called. 2011-06-28 14:30:23.468 INFO SDMPreferences com.sap.mobile.lib.sdmconfiguration.SDMPreferences.setStringPreference(SDMPreferences.java:244) Preference 'SAP_APPLICATIONID_HEADER_VALUE' (String) has been changed to MyApp.1.0.0.0 public Vector<LogEntry> getLogElementsByTag(final String aTag) public Vector<LogEntry> getLogElementsByTimeStamp(final long start, final long end) public Vector<LogEntry> getLogElementsByPID(final long PID) public Vector<LogEntry> getLogElementsByCorrelationId(final String correlationId)
These methods return with a Vector of filtered log entries, filtered by TAG, timestamp (interval), process id and correlation id, respectively.