本文整理了Java中com.amazonaws.logging.Log.isWarnEnabled()
方法的一些代码示例,展示了Log.isWarnEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Log.isWarnEnabled()
方法的具体详情如下:
包路径:com.amazonaws.logging.Log
类名称:Log
方法名:isWarnEnabled
[英]Is warn logging currently enabled?
Call this method to prevent having to perform expensive operations (for example, String
concatenation) when the log level is more than warn.
[中]当前是否启用了警告日志记录?
调用此方法以防止在日志级别超过warn时执行昂贵的操作(例如,String
串联)。
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Tries to ensure a connection is always cleaned-up correctly by calling
* {@link #releaseConnection()} on class destruction if the cleanup hasn't
* already been done.
* <p>
* This desperate cleanup act will only be necessary if the user of this
* class does not completely consume or close this input stream prior to
* object destruction. This method will log Warning messages if a forced
* cleanup is required, hopefully reminding the user to close their streams
* properly.
*/
@Override
protected void finalize() throws Throwable {
if (!alreadyReleased) {
if (log.isWarnEnabled()) {
log.warn("Attempting to release HttpMethod in finalize() as its response data stream has gone out of scope. "
+ "This attempt will not always succeed and cannot be relied upon! Please ensure S3 response data streams are "
+ "always fully consumed or closed to avoid HTTP connection starvation.");
}
releaseConnection();
if (log.isWarnEnabled()) {
log.warn("Successfully released HttpMethod in finalize(). You were lucky this time... "
+ "Please ensure S3 response data streams are always fully consumed or closed.");
}
}
super.finalize();
}
代码示例来源:origin: aws-amplify/aws-sdk-android
/**
* Constructs an input stream based on an {@link HttpMethod} object
* representing an HTTP connection. If a connection input stream is
* available, this constructor wraps the underlying input stream and makes
* that stream available. If no underlying connection is available, an empty
* {@link ByteArrayInputStream} is made available.
*
* @param httpMethod The HTTP method being executed, whose response content
* is to be wrapped.
*/
@SuppressWarnings("checkstyle:emptyblock")
public HttpMethodReleaseInputStream(HttpEntityEnclosingRequest httpMethod) {
this.httpRequest = httpMethod;
try {
this.in = httpMethod.getEntity().getContent();
} catch (IOException e) {
if (log.isWarnEnabled()) {
log.warn("Unable to obtain HttpMethod's response data stream", e);
}
try {
httpMethod.getEntity().getContent().close();
} catch (Exception ex) {
}
this.in = new ByteArrayInputStream(new byte[0]); // Empty input
// stream;
}
}
代码示例来源:origin: com.amazonaws/aws-android-sdk-core
/**
* Tries to ensure a connection is always cleaned-up correctly by calling
* {@link #releaseConnection()} on class destruction if the cleanup hasn't
* already been done.
* <p>
* This desperate cleanup act will only be necessary if the user of this
* class does not completely consume or close this input stream prior to
* object destruction. This method will log Warning messages if a forced
* cleanup is required, hopefully reminding the user to close their streams
* properly.
*/
@Override
protected void finalize() throws Throwable {
if (!alreadyReleased) {
if (log.isWarnEnabled()) {
log.warn("Attempting to release HttpMethod in finalize() as its response data stream has gone out of scope. "
+ "This attempt will not always succeed and cannot be relied upon! Please ensure S3 response data streams are "
+ "always fully consumed or closed to avoid HTTP connection starvation.");
}
releaseConnection();
if (log.isWarnEnabled()) {
log.warn("Successfully released HttpMethod in finalize(). You were lucky this time... "
+ "Please ensure S3 response data streams are always fully consumed or closed.");
}
}
super.finalize();
}
代码示例来源:origin: com.amazonaws/aws-android-sdk-core
/**
* Constructs an input stream based on an {@link HttpMethod} object
* representing an HTTP connection. If a connection input stream is
* available, this constructor wraps the underlying input stream and makes
* that stream available. If no underlying connection is available, an empty
* {@link ByteArrayInputStream} is made available.
*
* @param httpMethod The HTTP method being executed, whose response content
* is to be wrapped.
*/
@SuppressWarnings("checkstyle:emptyblock")
public HttpMethodReleaseInputStream(HttpEntityEnclosingRequest httpMethod) {
this.httpRequest = httpMethod;
try {
this.in = httpMethod.getEntity().getContent();
} catch (IOException e) {
if (log.isWarnEnabled()) {
log.warn("Unable to obtain HttpMethod's response data stream", e);
}
try {
httpMethod.getEntity().getContent().close();
} catch (Exception ex) {
}
this.in = new ByteArrayInputStream(new byte[0]); // Empty input
// stream;
}
}
内容来源于网络,如有侵权,请联系作者删除!