Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

weblogng/weblogng-client-iOS

Repository files navigation

Build Status

Usage

Using the WeblogNG iOS client library follows an easy three-step process:

  1. add the WNGLogger library dependency to your project
  2. integrate the WNGLogger library into your application
  3. create dashboard and charts with your metrics

Add the WNGLogger library dependency to your project

The WNGLogger library is available via CocoaPods and is the recommended installation path.

You can install it by adding a WNGLogger dependency to your Podfile:

pod 'WNGLogger', :git => 'https://github.com/weblogng/weblogng-client-iOS.git', :tag => '0.8.1'

Execute pod install. There should be some output like:

$ pod install
Analyzing dependencies
Pre-downloading: `WNGLogger` from `https://github.com/weblogng/weblogng-client-iOS.git`, tag `0.8.1`
Downloading dependencies
Using AFNetworking (2.4.1)
Using JRSwizzle (1.0)
Installing WNGLogger 0.8.1
Generating Pods project
Integrating client project

Integrate the WNGLogger library into your application

  1. sign-up for WeblogNG
  2. add the WNGLogger header file
  3. instantiate the Logger object using your api key and application name
    1. find or generate an api key on your WeblogNG account page
    2. recommendation: Store the sharedLogger in a convenient place to make it easy to use throughout the application
  4. send metrics with the values recorded by your application

Example

Here is some example code taken from the (super-simple) WeblogNG iOS Sample App for iOS that demonstrates the basic usage:

#import <WNGLogger/logger.h>
#import <WNGLogger/NSURLConnection+WNGLogging.h>

@implementation WNGAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSString *apiKey = @"specify your api key here";
    NSString *application = @"specify your application name here";

    [WNGLogger initSharedLogger:apiKey application:application];
    //enable automatic measurement of http requests!
    [NSURLConnection wng_enableLogging];

    [self someIntensiveLogic];

    //time execution of an arbitrary block
    [[WNGLogger sharedLogger] executeWithTiming:@"sample-app-anExpensiveBlock" aBlock:^(void){
        int millis_to_sleep = 250 + arc4random_uniform(250);
        float seconds_to_sleep = ((float) millis_to_sleep) / 1000;
        [NSThread sleepForTimeInterval:seconds_to_sleep];
    }];

    return YES;
}

- (void) someIntensiveLogic {
    NSString *metricName = @"sample-app-someIntensiveLogic";
    [[WNGLogger sharedLogger] recordStart:metricName];

    int millis_to_sleep = 500 + arc4random_uniform(250);
    float seconds_to_sleep = ((float) millis_to_sleep) / 1000;

    [NSThread sleepForTimeInterval:seconds_to_sleep];

    [[WNGLogger sharedLogger] recordFinishAndSendMetric:metricName];
}

@end

Create dashboard and charts with your application data

  1. run your app, executing code timed with the library; this will report raw metric data to the WeblogNG api
  2. go to WeblogNG, create a dashboard, and add a chart with your data

Resources

About

WeblogNG Client Library for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •