Skip to main content

Setup iOS

Requirements

  • The minimun compatible iOS Version for LogDog is iOS 15
  • LogDog can be used on other platforms (iPad, TV, Apple Vision) but we don't run test on these platforms)

Cocoa Package Manager

Add LogDog to your PodFile.

pod 'LogDogSDK'

To download a a specific version please check our Github

pod install --repo-update
info

If you have multiple targets in your podfile, you have to add LogDog for each of them.

API Key

  1. Create an account at client.logdog.app
  2. Copy your API key from the project settings

Initialize LogDog

Add the following code to your AppDelegate.swift:

import LogDog

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

override init() {
super.init()
LogDog.initialize()
let config = LogDogConfig(apiKey: "YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config: config)
LogDog.i("Hello from LogDog!")
}
}
info

To catch all logs, events and requests within your app it is important to init and start LogDog as early as possible. For example calling it in didFinishLaunchingWithOptions could be already to late depending on how your application works.

Or if you're using SwiftUI, add it to your app's main struct:

import SwiftUI
import LogDog

@main
struct YourApp: App {
init() {
LogDog.initialize()
let config = LogDogConfig(apiKey: "YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config: config)
LogDog.i("Hello from LogDog")
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

After launching the app the LogDog SDK will automatically create a new device for your account.

LogDog Devices

Verification

To verify that LogDog is properly installed and configured:

  1. Place a log statement like LogDog.i("Hello from LogDog!")
  2. Run your app
  3. Check the LogDog dashboard - you should see the log appear immediately

Available Methods

Setup and Configuration

// Initialize LogDog with your API key
let config = LogDogConfig(apiKey:"YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config:config)

// Set custom device name
LogDog.setCustomDeviceName(name: "iPhone 15 Pro Test Device")

// Check if LogDog is enabled
LogDog.isEnabled() -> Bool

Logging

Basic logging with LogDog

LogDog.l("Message")
LogDog.i("Info message")
LogDog.w("Warning message")
LogDog.e("Error message")

More advanced logging with the LogDog Logger.

 let logger = LogDogLogger(subsystem: "com.yourcompany.app", category: "main")
logger.l("Log Msg")
logger.i("Info Log Msg")
logger.d("Debug Log Msg")
logger.w("Warning Log Msg")
logger.e("Error Log Msg")
logger.n("Notice Log Msg")
logger.t("Trace Log Msg")
logger.c("Critical Log Msg")
logger.f("Fault Log Msg")

You can use both logging techniques individually or combined. The LogDogLogger uses the swift Logger behind the scenes and offers more features to filter your requests later on.

Event Tracking

// Send custom event
LogDog.logEvent(name: "SETTING_CHANGED", category: "GENERAL", payload: ["user-id":"1"])

Debug Options

// Enable/disable shake to toggle debug window in production builds; Is active by default
LogDog.setDebugShake(active: false)

// Get SDK version
LogDog.getVersion(): String

// Delete device ID
LogDog.deleteDeviceId()

Throttling Requests

To debounce requests and send them in bulk LogDog offers setRequestSendTimeout(timeoutInMs: Int)

LogDog.setRequestSendTimeout(timeoutInMs: 10_000) // 10s
LogDog.getRequestSendTimeout()

If set it will delay requests up to the defined time and then send multiple requests in bulk. Please note that this is a debounce, so every new request will again reset the timeout.

Tips

If you don't want write import LogDog in every file of your project it's possible to place the following statement in for example your AppDelegate.swift file.

@_exported import LogDog

Best Practices

  1. Initialize LogDog as early as possible in your app lifecycle
  2. Use appropriate log levels for different types of information
  3. Add relevant metadata to help with debugging
  4. Handle sensitive information appropriately
  5. Monitor network usage and adjust configuration if needed

Troubleshooting

If you're not seeing logs in the dashboard:

  1. Verify if your API key is correct
  2. Check that LogDog.initialize() and LogDog.start() have been called
  3. Ensure you have network connectivity on your desktop and your mobile device
  4. Check if any logs are being filtered by your configuration

Support

If you have questions send us an email via support@logdog.app. We are happy to help!