Skip to content

Commit 3839354

Browse files
author
jordanqin
committed
update qcloud sdk to 1.5.74
1 parent bf467bc commit 3839354

32 files changed

+1585
-473
lines changed

QCloudFoundation/.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QCloudFoundation/.idea/other.xml

Lines changed: 549 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QCloudFoundation/foundation/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
minSdkVersion 15
88
targetSdkVersion 28
99

10-
versionCode 10574
11-
versionName "1.5.73"
10+
versionCode 10575
11+
versionName "1.5.74"
1212

1313
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1414

@@ -29,6 +29,11 @@ android {
2929
lintOptions {
3030
abortOnError false
3131
}
32+
33+
compileOptions {
34+
sourceCompatibility = JavaVersion.VERSION_1_8
35+
targetCompatibility = JavaVersion.VERSION_1_8
36+
}
3237
}
3338

3439

@@ -46,6 +51,8 @@ dependencies {
4651
testCompileOnly 'org.mockito:mockito-core:1.10.19'
4752

4853
compileOnly 'androidx.appcompat:appcompat:1.0.0'
54+
55+
compileOnly project(':qcloud-track')
4956
}
5057

5158
project.extensions.add('artifactId', 'qcloud-foundation')

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/CallMetricsListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import androidx.annotation.NonNull;
2626

27-
import com.tencent.qcloud.core.logger.QCloudLogger;
27+
import com.tencent.qcloud.core.logger.COSLogger;
2828

2929
import java.io.IOException;
3030
import java.net.InetAddress;
@@ -96,7 +96,7 @@ public void dnsEnd(Call call, String domainName, List<InetAddress> inetAddressLi
9696
}
9797
}
9898
ipList.append("}");
99-
QCloudLogger.i(QCloudHttpClient.HTTP_LOG_TAG, "dns: " + domainName + ":" + ipList.toString());
99+
COSLogger.iNetwork(QCloudHttpClient.HTTP_LOG_TAG, "dns: " + domainName + ":" + ipList.toString());
100100
dnsLookupTookTime += System.nanoTime() - dnsStartTime;
101101
this.dnsInetAddressList = inetAddressList;
102102
}

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/CountingInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
package com.tencent.qcloud.core.http;
2424

2525
import com.tencent.qcloud.core.common.QCloudProgressListener;
26-
import com.tencent.qcloud.core.logger.QCloudLogger;
26+
import com.tencent.qcloud.core.logger.COSLogger;
2727

2828
import java.io.FilterInputStream;
2929
import java.io.IOException;
@@ -110,6 +110,6 @@ public synchronized void reset() throws IOException {
110110
@Override
111111
public void close() throws IOException {
112112
super.close();
113-
QCloudLogger.i("Test", "CountingInputStream is closed");
113+
COSLogger.iProcess("Test", "CountingInputStream is closed");
114114
}
115115
}

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
package com.tencent.qcloud.core.http;
2424

25-
import com.tencent.qcloud.core.logger.QCloudLogger;
25+
import com.tencent.qcloud.core.logger.COSLogger;
2626

2727
import java.text.ParseException;
2828
import java.text.SimpleDateFormat;
@@ -51,7 +51,7 @@ public static void calculateGlobalTimeOffset(String sDate, Date deviceDate, int
5151
long clockSkew = (serverDate.getTime() - deviceDate.getTime()) / 1000;
5252
if (Math.abs(clockSkew) >= minOffset) {
5353
GLOBAL_TIME_OFFSET.set(clockSkew);
54-
QCloudLogger.i(QCloudHttpClient.HTTP_LOG_TAG, "NEW TIME OFFSET is " + clockSkew + "s");
54+
COSLogger.iNetwork(QCloudHttpClient.HTTP_LOG_TAG, "NEW TIME OFFSET is " + clockSkew + "s");
5555
}
5656
} catch (ParseException e) {
5757
// parse error, ignored

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpLogger.java

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,18 @@
2222

2323
package com.tencent.qcloud.core.http;
2424

25-
import com.tencent.qcloud.core.logger.FileLogAdapter;
26-
import com.tencent.qcloud.core.logger.QCloudLogger;
27-
28-
import java.util.ArrayList;
29-
import java.util.List;
25+
import com.tencent.qcloud.core.logger.COSLogger;
3026

3127
import okhttp3.Response;
3228

3329
public class HttpLogger implements HttpLoggingInterceptor.Logger {
34-
35-
private boolean debuggable;
36-
private FileLogAdapter fileLogAdapter;
37-
private List<String> mRequestBufferLogs;
38-
3930
private String tag;
40-
41-
public HttpLogger(boolean debuggable, String tag) {
42-
43-
this.debuggable = debuggable;
31+
public HttpLogger(String tag) {
4432
this.tag = tag;
45-
mRequestBufferLogs = new ArrayList<>(10);
4633
}
4734

48-
HttpLogger(boolean debuggable) {
49-
this(debuggable, QCloudHttpClient.HTTP_LOG_TAG);
50-
}
51-
52-
public void setDebug(boolean debuggable) {
53-
this.debuggable = debuggable;
35+
HttpLogger() {
36+
this(QCloudHttpClient.HTTP_LOG_TAG);
5437
}
5538

5639
public void setTag(String tag) {
@@ -59,56 +42,16 @@ public void setTag(String tag) {
5942

6043
@Override
6144
public void logRequest(String message) {
62-
if (debuggable) {
63-
QCloudLogger.i(tag, message);
64-
}
65-
fileLogAdapter = QCloudLogger.getAdapter(FileLogAdapter.class);
66-
if (fileLogAdapter != null) {
67-
synchronized (mRequestBufferLogs){
68-
mRequestBufferLogs.add(message);
69-
}
70-
}
45+
COSLogger.iNetwork(tag, message);
7146
}
7247

7348
@Override
7449
public void logResponse(Response response, String message) {
75-
if (debuggable) {
76-
QCloudLogger.i(tag, message);
77-
}
78-
if (fileLogAdapter != null && response != null && !response.isSuccessful()) {
79-
flushRequestBufferLogs();
80-
fileLogAdapter.log(QCloudLogger.INFO, tag,
81-
message, null);
82-
} else {
83-
synchronized (mRequestBufferLogs){
84-
mRequestBufferLogs.clear();
85-
}
86-
}
50+
COSLogger.iNetwork(tag, message);
8751
}
8852

8953
@Override
9054
public void logException(Exception exception, String message) {
91-
QCloudLogger.i(tag, message);
92-
if (fileLogAdapter != null && exception != null) {
93-
flushRequestBufferLogs();
94-
fileLogAdapter.log(QCloudLogger.INFO, tag,
95-
message, exception);
96-
} else {
97-
synchronized (mRequestBufferLogs){
98-
mRequestBufferLogs.clear();
99-
}
100-
}
101-
}
102-
103-
private synchronized void flushRequestBufferLogs() {
104-
synchronized (mRequestBufferLogs){
105-
if (fileLogAdapter != null && mRequestBufferLogs.size() > 0) {
106-
for (String requestLog : mRequestBufferLogs) {
107-
fileLogAdapter.log(QCloudLogger.INFO, tag,
108-
requestLog, null);
109-
}
110-
mRequestBufferLogs.clear();
111-
}
112-
}
55+
COSLogger.iNetwork(tag, message);
11356
}
11457
}

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/NetworkClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public abstract class NetworkClient {
3434

3535
protected RetryStrategy retryStrategy;
3636
protected HttpLogger httpLogger;
37-
protected boolean enableDebugLog;
3837
protected Dns dns;
3938

4039
private QCloudRetryInterceptor retryInterceptor;
@@ -50,7 +49,6 @@ public void init(QCloudHttpClient.Builder b, HostnameVerifier hostnameVerifier,
5049
Dns dns, HttpLogger httpLogger){
5150
this.retryStrategy = b.retryStrategy;
5251
this.httpLogger = httpLogger;
53-
this.enableDebugLog = b.enableDebugLog;
5452
this.dns = dns;
5553
}
5654

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/QCloudHttpClient.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import androidx.annotation.NonNull;
2929

3030
import com.tencent.qcloud.core.auth.QCloudCredentialProvider;
31-
import com.tencent.qcloud.core.logger.QCloudLogger;
31+
import com.tencent.qcloud.core.logger.COSLogger;
3232
import com.tencent.qcloud.core.task.QCloudTask;
3333
import com.tencent.qcloud.core.task.RetryStrategy;
3434
import com.tencent.qcloud.core.task.TaskManager;
@@ -126,7 +126,7 @@ public List<InetAddress> lookup(String hostname) throws UnknownHostException {
126126
dns = Dns.SYSTEM.lookup(hostname);
127127
} catch (UnknownHostException e) {
128128
// e.printStackTrace();
129-
QCloudLogger.w(HTTP_LOG_TAG, "system dns failed, retry cache dns records.");
129+
COSLogger.wNetwork(HTTP_LOG_TAG, "system dns failed, retry cache dns records.");
130130
}
131131
}
132132

@@ -139,7 +139,7 @@ public List<InetAddress> lookup(String hostname) throws UnknownHostException {
139139
try {
140140
dns = connectionRepository.getDnsRecord(hostname);
141141
} catch (UnknownHostException e) {
142-
QCloudLogger.w(HTTP_LOG_TAG, "Not found dns in cache records.");
142+
COSLogger.wNetwork(HTTP_LOG_TAG, "Not found dns in cache records.");
143143
}
144144
}
145145

@@ -202,18 +202,13 @@ public void addDnsFetch(@NonNull QCloudDnsFetch dnsFetch){
202202
dnsFetchs.add(dnsFetch);
203203
}
204204

205-
public void setDebuggable(boolean debuggable) {
206-
httpLogger.setDebug(debuggable);
207-
}
208-
209205
private QCloudHttpClient(Builder b) {
210206
this.verifiedHost = new HashSet<>(5);
211207
this.dnsMap = new ConcurrentHashMap<>(3);
212208
this.dnsFetchs = new ArrayList<>(3);
213209
this.taskManager = TaskManager.getInstance();
214210
this.connectionRepository = ConnectionRepository.getInstance();
215-
httpLogger = new HttpLogger(false);
216-
setDebuggable(false);
211+
httpLogger = new HttpLogger();
217212

218213
// 默认的okhttp可以用来兜底
219214
this.okhttpNetworkClient = new OkHttpClientImpl();
@@ -349,7 +344,6 @@ public final static class Builder {
349344
QCloudHttpRetryHandler qCloudHttpRetryHandler;
350345
OkHttpClient.Builder mBuilder;
351346
NetworkClient networkClient;
352-
boolean enableDebugLog = false;
353347
List<String> prefetchHost = new LinkedList<>();
354348
boolean dnsCache = false;
355349
boolean verifySSLEnable = true;
@@ -397,11 +391,6 @@ public Builder setNetworkClient(NetworkClient networkClient){
397391
return this;
398392
}
399393

400-
public Builder enableDebugLog(boolean enableDebugLog){
401-
this.enableDebugLog = enableDebugLog;
402-
return this;
403-
}
404-
405394
public Builder addPrefetchHost(String host) {
406395
prefetchHost.add(host);
407396
return this;

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/StreamingRequestBody.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import com.tencent.qcloud.core.common.QCloudDigistListener;
2929
import com.tencent.qcloud.core.common.QCloudProgressListener;
30-
import com.tencent.qcloud.core.logger.QCloudLogger;
30+
import com.tencent.qcloud.core.logger.COSLogger;
3131
import com.tencent.qcloud.core.util.Base64Utils;
3232
import com.tencent.qcloud.core.util.OkhttpInternalUtils;
3333
import com.tencent.qcloud.core.util.QCloudUtils;
@@ -218,7 +218,7 @@ public InputStream getStream() throws IOException {
218218
if(url == null && inputStream != null && offset > 0) {
219219
long skiped = inputStream.skip(offset);
220220
if (skiped < offset) {
221-
QCloudLogger.w(QCloudHttpClient.HTTP_LOG_TAG, "skip %d is small than offset %d",
221+
COSLogger.wNetwork(QCloudHttpClient.HTTP_LOG_TAG, "skip %d is small than offset %d",
222222
skiped, offset);
223223
}
224224
}

0 commit comments

Comments
 (0)