Skip to content
Menu

Operations

Logging and debugging

Markdown version

Turn on SDK logging on iOS and Android, read the log, preview in-app messages and cards without a server, and confirm what reached Herald.

Turn on debug logging while you integrate, read what the SDK reports, and use the preview hooks to check your message UI without waiting for a real send.

Log levels

LeveliOSAndroidWhat it shows
None.noneLogLevel.NONENothing
Error.errorLogLevel.ERRORRejected batches, invalid calls (iOS), disk failures
Warning (default).warningLogLevel.WARNPlus invalid calls (Android), dropped keys, queue overflow, failed message fetches
Info.infoLogLevel.INFOPlus network failures and retry timing, messages that could not show yet
Debug.debugLogLevel.DEBUGPlus accepted batches (Android), events Herald rejected from an accepted batch, unchanged message fetches, discarded messages (Android), card impressions (iOS feed)

Set the level in the configuration. Use debug in development builds only.

swift
Herald.configure(appKey: "YOUR_APP_KEY", endpoint: URL(string: "https://YOUR_HERALD_HOST")!) { options in
    #if DEBUG
    options.logLevel = .debug
    #endif
}

Read the log

The SDK writes to the unified log under subsystem com.herald.sdk. Core messages use the category Herald; HeraldUI uses ui. In the Xcode console, filter by the subsystem. From a terminal, with a simulator running:

sh
xcrun simctl spawn booted log stream --level debug --predicate 'subsystem == "com.herald.sdk"'

On a device, use Console.app with the device selected and the same subsystem filter. Turn on Include Debug Messages in Console.app's Action menu to see debug lines.

Log lines name calls, statuses and card or message IDs. They do not contain event properties, attribute values or push tokens. On Android, a rejected batch line includes the first 300 characters of the server's error message.

What to look for

You seeIt meansNext step
Herald rejected a batch ...Herald returned a 4xx and the batch was droppedCheck the status in Error codes
... ignored: ...A call broke a rule and was dropped on the deviceFix the call; see Limits
Batch will be retried in N s (iOS) or will retry (Android)No network or a retryable statusNothing, unless it repeats for minutes
Event queue fullMore than 1,000 events waitedFind why uploads fail; check for a call in a tight loop
Message sync failed ...The fetch failed; cached messages are usedCheck the status and the user token
not shown (no presenter or no active scene)An in-app message is waitingInstall a presenter after configure
Sent N events (Android, debug)A batch was acceptedConfirm in Herald
Herald rejected event <id>: <reason> (<detail>) (debug)Herald kept the batch but left this event outFix the call; see Rejected events
Nothing at allconfigure never ran, or the level is too lowSet the level to debug and check configure is called

Inspect the traffic

To see the exact requests, run the app through an HTTPS debugging proxy you trust and filter for your Herald host. The SDK calls two paths: POST /api/v1/sdk/batch and GET /api/v1/sdk/messages. Their formats are on SDK REST endpoints.

To force an upload while you watch, call flush(), or send the app to the background.

Preview messages without a server

Two hooks load and show messages from JSON on the device, so designers and engineers can check every message type and card without an agent send.

Warning

debugLoadMessages and debugShowInAppMessage are public in every build, but they are for debug builds and internal preview screens only. Do not call them in production code paths. Wrap the calls in #if DEBUG (iOS) or if (BuildConfig.DEBUG) (Android), or keep them in a debug-only source set.

HookWhat it does
debugLoadMessages(json)Replaces the cards and in-app messages in memory with a GET /api/v1/sdk/messages response body. Nothing is saved, and the next real fetch replaces them. An unreadable body logs debugLoadMessages: unreadable body.
debugShowInAppMessage(messageId)Shows a loaded or fetched in-app message now, skipping its trigger, re-eligibility and the minimum interval. Your delegate is still asked on iOS. Does nothing while another message is on screen.
swift
#if DEBUG
func previewWelcomeModal() {
    guard let url = Bundle.main.url(forResource: "preview-messages", withExtension: "json"),
          let json = try? Data(contentsOf: url) else { return }
    Herald.shared.debugLoadMessages(json)
    Herald.shared.debugShowInAppMessage("msg_2")
}
#endif

Previewed messages behave like real ones: impressions, clicks and dismissals are queued and sent, and a shown message is recorded in the in-app history. Preview with a test connection and a test user.

Confirm what reached Herald

  1. Send the app to the background or call flush().
  2. Confirm the log shows no rejected batch.
  3. In Herald, open Audience > Search users (admin only) and look up the External ID. The profile shows the attributes and traits written for that user.

Herald has no screen for raw SDK events or devices today. If an event seems missing, check that the user is verified: under Optional verification, a batch without a token is stored as anonymous and writes nothing to the profile.

See Herald decide live →