Giter Club home page Giter Club logo

aliyun-log-ios-sdk's Introduction

Aliyun LOG iOS SDK

Language Build Status Carthage compatible

简介

阿里云日志服务SDK基于日志服务API实现,目前提供以下功能:
  • 写入日志(默认为HTTPS)
  • �断点续传(默认为HTTPS)

目前提供一下几种使用方式:

导入source code
  • 下载并将Source/AliyunLOGiOS文件夹拖入目标项目中.
  • 下载FMDB��并添加到工程依赖中,SDK目前引用FMDB的�2.7.5版本。
导入framework
  • 打开终端,cd到工程目录,然后执行
    sh build_both.sh
    
    ,然后会在工程根目录下生成Products文件夹,AliyunLOGiOS.framework,FMDB.framework均位于其中。
  • 将AliyunLOGiOS.framework,FMDB.framework拖入您的xcode project中
  • 确保General--Embedded Binaries中含有AliyunLOGiOS.framework以及依赖的FMDB.framework
  • 如果拖入framework没有选择copy,确保Build Phases--Embed Frameworks中含有此framework,并在Build Settings--Search Paths--Framework Search Paths中添加AliyunLOGiOS.framework,FMDB.framework的文件路径

打包脚本编译出来的framework库是Release版本,支持i386,x86_64,armv7,arm64的fat库

常见问题

1.工程编译出来的iOS库怎么没有支持armv7s的架构?

​ Xcode9中默认支持的架构是armv7/arm64,由于arm是向下兼容的,armv7的库在需要支持armv7s的app中也是适用的,如果仍然需要针对armv7s进行优化,那么需要如下图进行设置

list1

示例

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: "")
    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
        }
    }
Objective-C
	// - 如果是Objective-C工程的话,需要设置Build Settings -- Embedded Content Contains Swift Code 为 Yes


    NSString * ENDPOINT = @"******";
    NSString * PROJECTNAME = @"******";
    NSString * LOGSTORENAME = @"******";
    
    //        移动端是不安全环境,不建议直接使用阿里云主账号ak,sk的方式。建议使用STS方式。具体参见 https://help.aliyun.com/document_detail/62643.html
    //        注意:只建议在测试环境或者用户可以保证阿里云主账号AK,SK安全的前提下使用。
    
    //通过STS使用日志服务
    NSString * STS_AK = @"******";
    NSString * STS_SK = @"******";
    NSString * STS_TOKEN = @"******";
    
    LOGClient * client = [[LOGClient alloc] initWithEndPoint:ENDPOINT accessKeyID:STS_AK accessKeySecret:STS_SK token:STS_TOKEN projectName:PROJECTNAME];
    
    //  log调试开关
    client.mIsLogEnable = true;
    
    Log * loginfo = [[Log alloc] init];
    [loginfo PutContent:@"key001" value:@"value001"];
    
    LogGroup * group = [[LogGroup alloc] initWithTopic:@"topic" source:@"object-c"];
    [group PutLog:loginfo];
    
    [client PostLog:group logStoreName:LOGSTORENAME call:^(NSURLResponse *response,NSError *error) {
        NSLog(@"response %@", [response debugDescription]);
        NSLog(@"error %@",[error debugDescription]);
    }];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.