-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathcdn_get_log_list.c
60 lines (50 loc) · 1.67 KB
/
cdn_get_log_list.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "../qiniu/cdn.h"
#include "debug.h"
int main(int argc, char **argv) {
Qiniu_Client client;
Qiniu_CDN_LogListRet ret;
Qiniu_Error error;
int i, j;
char *accessKey = getenv("QINIU_ACCESS_KEY");
char *secretKey = getenv("QINIU_SECRET_KEY");
Qiniu_Mac mac;
mac.accessKey = accessKey;
mac.secretKey = secretKey;
//urls to refresh
char *domains[] = {
"csdk.qiniudn.com",
"javasdk.qiniudn.com"
};
int domainsCount = 2;
char *day = "2017-08-07";
//init
Qiniu_Zero(ret);
Qiniu_Client_InitMacAuth(&client, 1024, &mac);
error = Qiniu_CDN_GetLogList(&client, &ret, domains, domainsCount,day);
if (error.code != 200) {
printf("get domain logs error.\n");
debug_log(&client, error);
} else {
printf("get domain logs success.\n\n");
printf("Code: %d\n", ret.code);
printf("Error: %s\n", ret.error);
printf("Domains: %d\n", ret.domainsCount);
printf("-----------\n");
//data
for (i = 0; i < ret.domainsCount; i++) {
Qiniu_CDN_LogListData logData = ret.data[i];
if (logData.itemsCount == 0) {
printf("domain: %s, no log data\n", logData.domain);
printf("-----------\n");
} else {
printf("domain: %s have %d log files\n", logData.domain, logData.itemsCount);
for (j = 0; j < logData.itemsCount; j++) {
printf("name: %s\n", logData.items[j].name);
}
printf("-----------\n");
}
}
Qiniu_Free_CDNLogListRet(&ret);
}
Qiniu_Client_Cleanup(&client);
}