> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Debugging

> Reading the SDK's log, checking its state, and what each error means.

## The log

Set the log level when you initialize:

```swift theme={null}
KontextVideo.shared.initialize(with: .init(publisherToken: "…", logLevel: .debug))
```

Levels, each including the ones above it: `.none`, `.error`, `.warning` (the default), `.info`, `.debug`. At `.debug` the SDK logs every request and its answer, every ad with its price, every load, show and end with its reason, and every tracking event as it fires. The lines go to the unified log under the subsystem `so.kontext.video`; in Console.app, filter on that subsystem to see only the SDK.

Turn it back to `.warning` for release.

## The state

`initialize(with:)` reports where the SDK is, through its completion or as its `async` result:

| State | Meaning |
| - | - |
| `.enabled` | Ready |
| `.disabled(reason)` | Switched off by the server for this launch, for example an app version we no longer serve. No ads until the app restarts |
| `.failed` | We could not be reached at launch. Every ads request tries again first |

## Errors

Every call that cannot do its job throws, and a thrown error means nothing happened on screen. The ones you will meet while integrating:

| Error | What it means | What to do |
| - | - | - |
| `notInitialized` | `format()` before `initialize(with:)` | Initialize at launch |
| `noFill(reason)` | The server had nothing for the format | Normal: no advertiser wanted this moment. Ask again at the next one |
| `creativeFailed(code)` | The creative did not load within ten seconds | Rare; the ad is gone, ask again |
| `notLoaded` | `show()` before `load()` finished | Await `load()` first |
| `anotherAdShowing` | One ad on screen per app | Show it after the other ended |
| `invalidated(reason)` | The ad expired, was rejected or destroyed before `show()` | Ask for a new one |
| `containerTooSmall` | The view is too small for the creative | A bigger view, or reject |
| `presenterUnavailable` | Nothing on screen can hold the ad: no presenting controller for a linear ad, or the view for an overlay or pause ad is not in a window | Try again once the view is on screen, or pass the right one |
| `wrongPresentation` | `show()` on an overlay, `show(in:)` or `dismiss()` on a linear ad | Use the other method |

The full list is in the [API reference](https://docs.kontext.so/video/sdk/swift/api.md#videoaderror).

## When something looks off

1. Set `logLevel: .debug` and reproduce.
2. Copy the SDK's lines from the console, from `initialize` to the moment it went wrong.
3. Send them to [support@kontext.so](mailto:support@kontext.so) with your publisher token and the ad id from the log.

The log carries everything we need to replay what happened on our side.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.