All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.payu.sdk.api.log.AndroidLog Maven / Gradle / Ivy

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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy