iOS SDK の使用方法
    • PDF

    iOS SDK の使用方法

    • PDF

    Article Summary

    Classic/VPC環境で利用できます。

    iOS SDKの使用方法

    この章ではEffective Log Search & Analytics NELO iOS SDKの使用方法をご説明します。

    Effective Log Search & Analytics NELO iOSは次の機器とOSをサポートします。

    iPhone 4S, 5, 5c, 5s 以上 (armv7/arm64)
    iOS 8.0 以上
    

    ダウンロード

    最新配布バージョンは Fatバイナリーの形で提供されます。iOSはi386シミュレータと(armv7/arm64) デバイスアーキテクチャ用バイナリーを含めています。

    APIリスト

    “NeloLog” クラスで以下のようなAPIを提供します。

    // Default NeloLog init method
    + (bool) init:(NSString *)server ofProjectName:(NSString*)appName withProjectVersion:(NSString*)appVersion;
    + (bool) init:(NSString *)server ofProjectName:(NSString*)appName withProjectVersion:(NSString*)appVersion forUserId:(NSString*)userId;
    
    // send log method
    + (void) debug:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) error:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) fatal:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) info:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) warn:(NSString*)errorCode withMessage:(NSString*)message;
    
    + (void) debug:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) error:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) fatal:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) info:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) warn:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    
    + (void) setUserId:(NSString*)userId;
    + (void) setLogType:(NSString*)logType;
    + (void) setLogSource:(NSString*) logSource;
    + (void) setCrashBlock:(void (^)(void))block;
    + (void) setLogLevelFilter:(NSString*)logLevelFilter;
    + (void) setNeloSendMode:(NSString*)sendMode;
    
    + (void) enableClientSideSymbolication:(bool)enable;
    + (NSArray *) getReservedFields;
    + (NSDictionary *) getNeloSendMode;
    + (NSDictionary *) getNeloLogLevel;
    

    NELO SDK の使用方法

    Nelo SDK Frameworkの追加

    1. “Frameworks”に NELO2SDK.frameworkとCrashReporter.frameworkを追加します。

    elsa-1-4-2.png
    [画像- Framweorksに追加されたNELO iOS SDK]

    1. “Build Phases”の“Link Binary With Libraries” 項目に以下のシステムフレームワークを追加します。
    UIKit.framework
    SystemConfiguration.framework
    CoreTelephony.framework
    Foundation.framework
    

    elsa-1-4-3.png
    [画像 - Build Phasesに追加されたシステムフレームワーク]

    APIの詳細な説明

    初期化関数

    // Default NeloLog init method
    + (bool) init:(NSString *)server ofProjectName:(NSString*)appName withProjectVersion:(NSString*)appVersion;
    + (bool) init:(NSString *)server ofProjectName:(NSString*)appName withProjectVersion:(NSString*)appVersion forUserId:(NSString*)userId;
    
    参考

    SDK Version 0.32から onPort, byProtocol パラメータが除去されました。

    Parameters

    • server : Effective Log Search & Analytics 収集サーバのアドレス(以下の転送サーバを参照)
    • appName : Effective Log Search & Analyticsに登録されたプロジェクトID
    • appVersion : Effective Log Search & Analyticsに転送するAppのパージョン、このバージョンで Symbolicationの際、シンボルファイルとマッピング
    • userId : ユーザーのID情報

    転送サーバ

    iOS SDKはHTTPS ロトコルを利用してログを転送します。

    • Collector サーバアドレス
      • elsa-col.ncloud.com

    ログの転送

    // send log method
    + (void) debug:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) error:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) fatal:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) info:(NSString*)errorCode withMessage:(NSString*)message;
    + (void) warn:(NSString*)errorCode withMessage:(NSString*)message;
    
    + (void) debug:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) error:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) fatal:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) info:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    + (void) warn:(NSString*)errorCode withMessage:(NSString*)message atLocation:(NSString*)location;
    

    Parameters

    • errorCode : NELOのerrorCodeフィールドにマッピングされる。長さ制限あり(128字)。
    • message : NELOのbodyフィールドにマッピングされる。長さ制限なし(全体ログ容量の制限あり)。
    • location : NELOのlocationフィールドにマッピングされる。errorは発生した位置を転送

    使用方法

    [NeloLog info:@"ErrorCode" withMessage:@"Message"];
    

    その他関数

    + (void) setUserId:(NSString*)userId;
    + (void) setLogType:(NSString*)logType;
    + (void) setLogSource:(NSString*) logSource;
    + (void) setCrashBlock:(void (^)(void))block;
    + (void) setLogLevelFilter:(NSString*)logLevelFilter;
    + (void) setNeloSendMode:(NSString*)sendMode;
    // Client Side Symbolication
    + (void) enableClientSideSymbolication:(bool)enable;
    

    setCrashBlock

    • Crash Callback 関数

    • 当該block関数にCrash発生の際のに作動するコードを作成すると、クラッシュが発生してクラッシュ転送の際に当該コードを実行してから転送する

      • コードの例
        [NeloLog setCrashBlock:^{
            NSLog(@"crashed");
            [NeloLog setCustomField:@"MyValue" forKey:@"MyKey"];
        }];
        

    setLogLevelFilter

    • 特定のログ以上でのみ転送するようにログレベルを設定する関数
    • 以下に定義されたレベルのみ設定可能で、設定されたレベル以上のログのみ転送
      • DEBUG < INFO < WARN < ERROR < FATAL
      • 値は以下の Constant値で定義されている
        • NELO2_LOGLEVEL_DEBUG
        • NELO2_LOGLEVEL_INFO
        • NELO2_LOGLEVEL_WARN
        • NELO2_LOGLEVEL_ERROR
        • NELO2_LOGLEVEL_FATAL
    • 基本値は DEBUG
    • コードの例
      [NeloLog setLogLevelFilter:NELO2_LOGLEVEL_WARN];
      

    setNeloSendMode

    • IOS SDKは以下と同じ転送モードをサポートする
      • ALL: ネットワークに接続されていればログを転送
      • WIFI:ネットワークがWIFI 状態の時のみログを転送
      • 基本値はALL

    enableClientSideSymbolication

    • Symbolicationクライアントで実行するかを設定
    • 基本値は以下の通りである
      • IOS SDK: false(クライアントで Symbolication作業をしない)
      • MAC SDK: true(クライアントでSymbolication作業を実行する)
    • クライアントで Symbolication 作業を実行すると、クラッシュ発生の際にアプリが中止される時、若干の遅延が発生

    Effective Log Search & Analytics iOS SDK基本使用の例

    NSString* appID = @"02b96c3d8bbe_elsa-test";
    NSString* appVer= @"1.0.0";
    NSString* serverAddr = @"elsa-col.ncloud.com"; //Effective Log Search & Analytics 収集サーバアドレス
    NSString* userID = @"tester"; //ユーザーID
    
    
    // Nelo Init
    [NeloLog init:serverAddr ofProjectName:appID withProjectVersion:appVer forUserId:userID];
    
    // Neloログの転送
    [NeloLog info:@"ErrorCode" withMessage:@"Message"];
    [NeloLog error:@"ErrorCode" withMessage:@"Message" atLocation:@"test loc"];
    

    FAQ

    1. bitcode enabled のアプリはdSYMs(Symbol)はどこで取得できますか?

    XcodeまたはiTunes Connectで取得できます。

    • iTunes Connectを使用してDebug Symbolsをダウンロードする場合"My Apps"のアプリのビルドリストから必要なバージョンを選択します。"Download dSYM"を選択するとダウンロードできます。

    この記事は役に立ちましたか?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.