com.payu.sdk.api.log.AndroidLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-client Show documentation
Show all versions of api-client Show documentation
A fresh implementation of the PayU API Client for Android
The newest version!
package com.payu.sdk.api.log;
import android.util.Log;
/** A {@link ApiLog logger} for Android. */
public class AndroidLog implements ApiLog {
private static final int LOG_CHUNK_SIZE = 4000;
private final String tag;
public AndroidLog() {
this.tag = ApiLog.TAG;
}
@Override public final void log(String message) {
for (int i = 0, len = message.length(); i < len; i += LOG_CHUNK_SIZE) {
int end = Math.min(len, i + LOG_CHUNK_SIZE);
logChunk(message.substring(i, end));
}
}
/**
* Called one or more times for each call to {@link #log(String)}. The length of {@code chunk}
* will be no more than 4000 characters to support Android's {@link Log} class.
*/
public void logChunk(String chunk) {
android.util.Log.d(getTag(), chunk);
}
public String getTag() {
return tag;
}
}