Giter Site home page Giter Site logo

aliyun-log-ios-sdk's Introduction

Aliyun LOG iOS SDK

Language Build Status Carthage compatible

简介

阿里云日志服务SDK基于日志服务API实现,目前提供以下功能:
  • 写入日志

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

使用CocoaPods
  • 敬请期待
使用Carthage
  • 创建一个 Cartfile,列出所需要的framework,运行carthage bootstrap.
  • 根据这个说明 来添加 $(SRCROOT)/Carthage/Build/iOS/AliyunLOGiOS.framework 到iOS项目中
导入source code
  • 下载并将Source/AliyunLOGiOS文件夹拖入目标项目中.
导入framework
  • 根据需要可以选择构建i386或者arm的framework,也可以选择同时构建。

build i386 framework

cd aliyun-log-ios-sdk
cd Source
bash build_i386.sh
cd Products
ls

build arm framework

cd aliyun-log-ios-sdk
cd Source
bash build_arm.sh
cd Products
ls

build both

cd aliyun-log-ios-sdk
cd Source
bash build_both.sh
cd Products
ls
  • 执行之后,会在Products文件夹下生成AliyunLOGiOS.framework文件.
  • 将framework拖入xcode project中
  • 确保General--Embedded Binaries中含有此framework
  • 如果拖入framework没有选择copy,确保Build Phases--Embed Frameworks中含有此framework,并在Build Settings--Search Paths--Framework Search Paths中添加aliyun-log-ios-sdk.framework的文件路径
  • 如果是Objective-C工程的话,需要设置Build Settings -- Embedded Content Contains Swift Code 为 Yes
  • 修改安全协议:
    • 由于目前SDK只支持http协议,所以需要进行如下修改:

    • 右键点击项目的Info.plist选择open as -- source code ,添加类似如下的配置:

       <key>NSAppTransportSecurity</key>
       <dict>
       	<key>NSAllowsArbitraryLoads</key>
       	<true/>
       </dict>
      

示例

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: "")
Objective-C:
/*
    通过EndPoint、accessKeyID、accessKeySecret 构建日志服务客户端
    @endPoint: 服务访问入口,参见 https://help.aliyun.com/document_detail/29008.html
*/
LOGClient *myClient = [[LOGClient alloc]initWithEndPoint:@"XXX" accessKeyID:@"XXX" accessKeySecret:@"XXX" projectName:@"XXX" error:NULL];
    
/* 创建logGroup */    
LogGroup *logGroup = [[LogGroup alloc] initWithTopic:@"topic_test" source:@"source_test"];

	/* 存入一条log */
    Log *log1 = [[Log alloc] init];
    [log1 PutContent:@"K11" value:@"V11" error:NULL];
    [log1 PutContent:@"K12" value:@"V12" error:NULL];
    [log1 PutContent:@"K13" value:@"V13" error:NULL];
    [logGroup PutLog:log1];
    
    /* 存入一条log */
    Log *log2 = [[Log alloc] init];
    [log2 PutContent:@"K21" value:@"V21" error:NULL];
    [log2 PutContent:@"K22" value:@"V22" error:NULL];
    [log2 PutContent:@"K23" value:@"V23" error:NULL];
    [logGroup PutLog:log2];

 /* 发送 log */    
[myClient PostLog:logGroup logStoreName:@"XXX"];

aliyun-log-ios-sdk's People

Contributors

zzboy avatar

Watchers

 avatar  avatar  avatar

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.