com.amazonaws.logging.Log.isDebugEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中com.amazonaws.logging.Log.isDebugEnabled()方法的一些代码示例,展示了Log.isDebugEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Log.isDebugEnabled()方法的具体详情如下:
包路径:com.amazonaws.logging.Log
类名称:Log
方法名:isDebugEnabled

Log.isDebugEnabled介绍

[英]Is debug logging currently enabled?

Call this method to prevent having to perform expensive operations (for example, String concatenation) when the log level is more than debug.
[中]调试日志记录当前是否启用?
调用此方法以防止在日志级别高于调试级别时执行昂贵的操作(例如,String串联)。

代码示例

代码示例来源:origin: aws-amplify/aws-sdk-android

public synchronized void updateProgress(long bytes) {
  this.bytesTransferred += bytes;
  if (totalBytesToTransfer > -1
      && this.bytesTransferred > this.totalBytesToTransfer) {
    this.bytesTransferred = this.totalBytesToTransfer;
    if (log.isDebugEnabled()) {
      log.debug("Number of bytes transfered is more than the actual total bytes to transfer. Total number of bytes to Transfer : "
          + totalBytesToTransfer
          + ". Bytes Transferred : "
          + (bytesTransferred + bytes));
    }
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

public void buffer(byte read) {
  pos = -1;
  if (byteBuffered >= maxBufferSize) {
    if (log.isDebugEnabled()) {
      log.debug("Buffer size " + maxBufferSize
          + " has been exceeded and the input stream "
          + "will not be repeatable. Freeing buffer memory");
    }
    bufferSizeOverflow = true;
  }
  else
    bufferArray[byteBuffered++] = read;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

public void buffer(byte[] array, int offset, int length) {
  pos = -1;
  if (byteBuffered + length > maxBufferSize) {
    if (log.isDebugEnabled()) {
      log.debug("Buffer size " + maxBufferSize
          + " has been exceeded and the input stream "
          + "will not be repeatable. Freeing buffer memory");
    }
    bufferSizeOverflow = true;
  }
  else {
    System.arraycopy(array, offset, bufferArray, byteBuffered, length);
    byteBuffered += length;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Closes the given Closeable quietly.
 *
 * @param is the given closeable
 * @param log logger used to log any failure should the close fail
 */
public static void closeQuietly(Closeable is, Log log) {
  if (is != null) {
    try {
      is.close();
    } catch (final IOException ex) {
      if (logger.isDebugEnabled()) {
        logger.debug("Ignore failure in closing the Closeable", ex);
      }
    }
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

private static void loadRegionsFromOverrideFile() throws FileNotFoundException {
  String overrideFilePath = System.getProperty(REGIONS_FILE_OVERRIDE_SYSTEM_PROPERTY);
  if (log.isDebugEnabled()) {
    log.debug("Using local override of the regions file ("
        + overrideFilePath
        + ") to initiate regions data...");
  }
  File regionsFile = new File(overrideFilePath);
  FileInputStream override = new FileInputStream(regionsFile);
  initRegions(override);
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
public void mark(int readlimit) {
  abortIfNeeded();
  this.markPoint += bytesReadPastMarkPoint;
  this.bytesReadPastMarkPoint = 0;
  if (log.isDebugEnabled()) {
    log.debug("Input stream marked at " + this.markPoint + " bytes");
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Fetches the region of the bucket from the cache maintained. If the cache
 * doesn't have an entry, fetches the region from Amazon S3 and updates the
 * cache.
 */
private String fetchRegionFromCache(String bucketName) {
  String bucketRegion = bucketRegionCache.get(bucketName);
  if (bucketRegion == null) {
    if (log.isDebugEnabled()) {
      log.debug("Bucket region cache doesn't have an entry for " + bucketName
          + ". Trying to get bucket region from Amazon S3.");
    }
    bucketRegion = getBucketRegionViaHeadRequest(bucketName);
    if (bucketRegion != null) {
      bucketRegionCache.put(bucketName, bucketRegion);
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("Region for " + bucketName + " is " + bucketRegion);
  }
  return bucketRegion;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Standard input stream close method, except it ensures that
 * {@link #releaseConnection()} is called before the input stream is closed.
 *
 * @see java.io.InputStream#close()
 */
@Override
public void close() throws IOException {
  if (!alreadyReleased) {
    releaseConnection();
    if (log.isDebugEnabled()) {
      log.debug("Released HttpMethod as its response data stream is closed");
    }
  }
  in.close();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Failsafe method to initialize the regions list from the list bundled with
 * the SDK, in case it cannot be fetched from the remote source.
 */
private static void initSDKRegions() {
  if (log.isDebugEnabled()) {
    log.debug("Initializing the regions with default regions");
  }
  regions = RegionDefaults.getRegions();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Resets the input stream to the last mark point, or the beginning of the
 * stream if there is no mark point, by creating a new FileInputStream based
 * on the underlying file.
 *
 * @throws IOException when the FileInputStream cannot be re-created.
 */
@Override
public void reset() throws IOException {
  this.fis.close();
  abortIfNeeded();
  this.fis = new FileInputStream(file);
  long skipped = 0;
  long toSkip = markPoint;
  while (toSkip > 0) {
    skipped = this.fis.skip(toSkip);
    toSkip -= skipped;
  }
  if (log.isDebugEnabled()) {
    log.debug("Reset to mark point " + markPoint
        + " after returning " + bytesReadPastMarkPoint + " bytes");
  }
  this.bytesReadPastMarkPoint = 0;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Standard input stream available method, except it ensures that
 * {@link #releaseConnection()} is called if any errors are encountered from
 * the wrapped stream.
 *
 * @see java.io.InputStream#available()
 */
@Override
public int available() throws IOException {
  try {
    return in.available();
  } catch (IOException e) {
    releaseConnection();
    if (log.isDebugEnabled()) {
      log.debug("Released HttpMethod as its response data stream threw an exception", e);
    }
    throw e;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
public int read() throws IOException {
  final byte[] tmp = new byte[1];
  final int count = read(tmp, 0, 1);
  if (count != -1) {
    if (log.isDebugEnabled()) {
      log.debug("One byte read from the stream.");
    }
    final int unsignedByte = tmp[0] & BIT_MASK;
    return unsignedByte;
  } else {
    return count;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Gets an instance of {@link Mimetypes} with default mime type info. You
 * can load more via {@link #loadAndReplaceMimetypes(InputStream)}.
 * <p>
 * For more information about Internet media types, please read RFC 2045,
 * 2046, 2047, 2048, and 2077. The Internet media type registry is at
 * http://www.iana.org/assignments/media-types/
 * </p>
 *
 * @return an instance of {@link Mimetypes}
 */
public static synchronized Mimetypes getInstance() {
  if (mimetypes != null)
    return mimetypes;
  mimetypes = new Mimetypes();
  if (log.isDebugEnabled()) {
    Map<String, String> map = mimetypes.extensionToMimetypeMap;
    for (String extension : map.keySet()) {
      log.debug("Setting mime type for extension '" + extension + "' to '"
          + map.get(extension) + "'");
    }
  }
  return mimetypes;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * The read limit parameter is ignored if an internal buffer is being used
 * because the underlying input stream does not support mark, or INTEGER_MAX
 * if underlying input stream does support marking.
 */
@Override
public synchronized void mark(int readlimit) {
  abortIfNeeded();
  if (!isAtStart) {
    throw new UnsupportedOperationException(
        "Chunk-encoded stream only supports mark() at the start of the stream.");
  }
  if (is.markSupported()) {
    if (log.isDebugEnabled()) {
      log.debug("AwsChunkedEncodingInputStream marked at the start of the stream "
          + "(will directly mark the wrapped stream since it's mark-supported).");
    }
    is.mark(Integer.MAX_VALUE);
  } else {
    if (log.isDebugEnabled()) {
      log.debug("AwsChunkedEncodingInputStream marked at the start of the stream "
          + "(initializing the buffer since the wrapped stream is not mark-supported).");
    }
    decodedStreamBuffer = new DecodedStreamBuffer(maxBufferSize);
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Returns the hex-encoded MD5 hash String of the given message body.
 */
private static String calculateMessageBodyMd5(String messageBody) {
  if (log.isDebugEnabled()) {
    log.debug("Message body: " + messageBody);
  }
  byte[] expectedMd5;
  try {
    expectedMd5 = Md5Utils.computeMD5Hash(messageBody.getBytes(UTF8));
  } catch (Exception e) {
    throw new AmazonClientException(
        "Unable to calculate the MD5 hash of the message body. " + e.getMessage(), e);
  }
  String expectedMd5Hex = BinaryUtils.toHex(expectedMd5);
  if (log.isDebugEnabled()) {
    log.debug("Expected  MD5 of message body: " + expectedMd5Hex);
  }
  return expectedMd5Hex;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Standard input stream read method, except it calls
 * {@link #releaseConnection} when the underlying input stream is consumed.
 *
 * @see java.io.InputStream#read()
 */
@Override
public int read() throws IOException {
  try {
    int read = in.read();
    if (read == -1) {
      underlyingStreamConsumed = true;
      if (!alreadyReleased) {
        releaseConnection();
        if (log.isDebugEnabled()) {
          log.debug("Released HttpMethod as its response data stream is fully consumed");
        }
      }
    }
    return read;
  } catch (IOException e) {
    releaseConnection();
    if (log.isDebugEnabled()) {
      log.debug("Released HttpMethod as its response data stream threw an exception", e);
    }
    throw e;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Standard input stream read method, except it calls
 * {@link #releaseConnection} when the underlying input stream is consumed.
 *
 * @see java.io.InputStream#read(byte[], int, int)
 */
@Override
public int read(byte[] b, int off, int len) throws IOException {
  try {
    int read = in.read(b, off, len);
    if (read == -1) {
      underlyingStreamConsumed = true;
      if (!alreadyReleased) {
        releaseConnection();
        if (log.isDebugEnabled()) {
          log.debug("Released HttpMethod as its response data stream is fully consumed");
        }
      }
    }
    return read;
  } catch (IOException e) {
    releaseConnection();
    if (log.isDebugEnabled()) {
      log.debug("Released HttpMethod as its response data stream threw an exception", e);
    }
    throw e;
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Used to truly release the underlying resources.
 */
private void doRelease() {
  try {
    in.close();
  } catch (final Exception ex) {
    if (log.isDebugEnabled()) {
      log.debug("FYI", ex);
    }
  }
  if (in instanceof Releasable) {
    // This allows any underlying stream that has the close operation
    // disabled to be truly released
    final Releasable r = (Releasable)in;
    r.release();
  }
  abortIfNeeded();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
public int read(byte[] b, int off, int len) throws IOException {
  abortIfNeeded();
  if (b == null) {
    throw new NullPointerException();
  } else if (off < 0 || len < 0 || len > b.length - off) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return 0;
  }
  if (null == currentChunkIterator
      || !currentChunkIterator.hasNext()) {
    if (isTerminating) {
      return -1;
    } else {
      isTerminating = setUpNextChunk();
    }
  }
  final int count = currentChunkIterator.read(b, off, len);
  if (count > 0) {
    isAtStart = false;
    if (log.isDebugEnabled()) {
      log.debug(count + " byte read from the stream.");
    }
  }
  return count;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Retrieves the region of the bucket by making a HeadBucket request to
 * us-west-1 region. Currently S3 doesn't return region in a HEAD Bucket
 * request if the bucket owner has enabled bucket to accept only SigV4
 * requests via bucket policies.
 */
private String getBucketRegionViaHeadRequest(String bucketName) {
  String bucketRegion = null;
  try {
    final String endpoint = "https://s3-us-west-1.amazonaws.com";
    final Request<HeadBucketRequest> request = createRequest(bucketName, null,
        new HeadBucketRequest(bucketName), HttpMethodName.HEAD, new URI(endpoint));
    final HeadBucketResult result = invoke(request, new HeadBucketResultHandler(),
        bucketName, null);
    bucketRegion = result.getBucketRegion();
  } catch (final AmazonS3Exception exception) {
    if (exception.getAdditionalDetails() != null) {
      bucketRegion = exception.getAdditionalDetails().get(
          Headers.S3_BUCKET_REGION);
    }
  } catch (final URISyntaxException e) {
    log.warn("Error while creating URI");
  }
  if (bucketRegion == null && log.isDebugEnabled()) {
    log.debug("Not able to derive region of the " + bucketName
        + " from the HEAD Bucket requests.");
  }
  return bucketRegion;
}

相关文章