OTAliyunLog 1.2.1

OTAliyunLog 1.2.1

jhbshow 维护。



  • cuirhong

OTLog

阿里云日志上传


接入(cocopods集成)

  1. 在 Podfile 文件中添加:
pod 'OTAliyunLog'
  1. 引入头文件:
  • OC
@import OTAliyunLog;
  • swift:
import OTAliyunLog

使用方法

Objective-C

  • 初始化参数
NSString *regionEndpoint = @"cn-shenzhen.log.aliyuncs.com";
NSString * logStoreName = @"jhb-logstore-test";
NSString * projectName = @"jhb-log-test";
NSString * accessKeySecret = @"CYFJz************62i0P";
NSString * accessKeyId = @"LTAI4F************YoipRi";
OTLogConfig *config = [[OTLogConfig alloc]initWithEndPoint:regionEndpoint accessKeyID:accessKeyId accessKeySecret:accessKeySecret projectName:projectName logStoreName:logStoreName token:NULL];
[OTLogManager.sharedInstance setupConfigWithLogConfig:config];
  • 上传日志
OTLogModel *logModel = [[OTLogModel alloc]init];
[logModel PutContent:@"url" value:@"/test/url"];
[logModel PutContent:@"userId" value:@"23232"];
OTLogGroupModel *logGroupModel = [[OTLogGroupModel alloc] initWithLogTopic:@"topic-20200616" logSource:@"source-20200616" logContents:@[logModel] logTagContentMap:NULL];
[[OTLogManager sharedInstance] postLog:logGroupModel call:^(OTPostLogResult * result) {
    NSLog(@"%@",[result.response description]);
}];
  • 保存日志
OTLogModel *logModel = [[OTLogModel alloc]init];
[logModel PutContent:@"url" value:@"/test/url"];
[logModel PutContent:@"userId" value:@"23232"];
OTLogGroupModel *logGroupModel = [[OTLogGroupModel alloc] initWithLogTopic:@"topic-20200616" logSource:@"source-20200616" logContents:@[logModel] logTagContentMap:NULL];
[[OTLogManager sharedInstance] saveLogWithLogGroupModel:logGroupModel];
  • 上传本地日志(每60秒上传一次)
[[OTLogManager sharedInstance] startUploadLogWithTimeInterval:60];

SDK 更新

  1. 打 tag(SDK 对应的版本),推送到 git 仓库
git tag 1.0.0
git push --tags
  1. 更新 OTAliyunLog.podspec 文件中的 version(与上述 tag 对应)
spec.version      = "1.0.0"
  1. git 仓库发布最新的 tag 版本

  2. 发布到 CocoaPods:

pod trunk push OTAliyunLog.podspec --allow-warnings --verbose
  1. 更新 SDK 后,pod install 找不到
pod install --repo-update