阿里云日志服务 iOS SDK 基于日志服务 API实现,目前提供写入日志的功能。
Swift
/*
通过EndPoint、accessKeyID、accessKeySecret 构建日志服务客户端
@endPoint: 服务访问入口,参见 https://help.aliyun.com/document_detail/29008.html
*/
let myClient = try! LOGClient(endPoint: "",
accessKeyID: "",
accessKeySecret: "",
projectName:"")
/* 创建logGroup */
let logGroup = try! LogGroup(topic: "mTopic",source: "mSource")
/* 存入一条log */
let log1 = Log()
try! log1.PutContent("K11", value: "V11")
try! log1.PutContent("K12", value: "V12")
try! log1.PutContent("K13", value: "V13")
logGroup.PutLog(log1)
/* 存入一条log */
let log2 = Log()
try! log2.PutContent("K21", value: "V21")
try! log2.PutContent("K22", value: "V22")
try! log2.PutContent("K23", value: "V23")
logGroup.PutLog(log2)
/* 发送 log */
myClient.PostLog(logGroup,logStoreName: ""){ response, error in
// handle response however you want
if error?.domain == NSURLErrorDomain && error?.code == NSURLErrorTimedOut {
print("timed out") // note, `response` is likely `nil` if it timed out
}
}
在文档使用中是否遇到以下问题
更多建议
匿名提交