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

# How to collect logs

> How to read SDK logs while you develop.

## iOS

<Tabs>
  <Tab title="When you can build locally with Xcode">
    <Steps>
      <Step title="Check the logLevel setting">
        Make sure the log callback is attached when you initialize the SDK.

        ```swift theme={null}
        OneS1ght.onDebugLog = { level, line in print("[OneS1ght][\(level)] \(line)") }
        ```

        <Warning>
          Register it **before** `initialize` so that logs from the initialization step are captured.
        </Warning>

        You can filter by level. `LogLevel` is `Comparable`.

        ```swift theme={null}
        OneS1ght.onDebugLog = { level, line in
            guard level >= .warn else { return }      // only what needs a look
            print("[OneS1ght][\(level)] \(line)")
        }
        ```

        <Note>
          Before `0.1.12` only the text was passed — `{ line in ... }`.
          See the [migration guide](/sdk/integration/ios/migration-guide).
        </Note>
      </Step>

      <Step title="Connect the device">
        Connect the iOS device to your Mac.
      </Step>

      <Step title="Build and run the app">
        Build the app in Xcode and install and run it on the connected device.
      </Step>

      <Step title="Set the console filter">
        Open the **Console** tab at the bottom of Xcode.
        Type `OneS1ght` into the filter field at the bottom right so that only OneS1ght logs are shown.
      </Step>

      <Step title="Reproduce the issue">
        Reproduce the situation where the problem occurs.
      </Step>

      <Step title="Save the logs">
        Keep the app in the foreground for about **30 seconds**.
        Select all the logs in the Console, copy them, paste them into a text editor and save the file.
      </Step>
    </Steps>
  </Tab>

  <Tab title="When you use the Console app">
    If you cannot build onto the iOS device from Xcode, you can collect logs with the **Console** app on your Mac.

    <Steps>
      <Step title="Connect the device">
        Connect the iOS device to your Mac.
      </Step>

      <Step title="Open the Console app">
        Search for "Console" in Spotlight (`Cmd + Space`) and launch the app.
      </Step>

      <Step title="Start the log stream">
        Select the connected iOS device from the device list in the Console app's left sidebar.
        Type your **app's bundle ID** into the search/filter field at the top to filter the stream.
      </Step>

      <Step title="Clear previous logs">
        Right-click the Console window and choose **Clear Console** to remove earlier logs.
      </Step>

      <Step title="Reproduce the issue">
        Reproduce the situation where the problem occurs.
      </Step>

      <Step title="Save the logs">
        Keep the app in the foreground for about **30 seconds**.
        Select all the logs shown, copy them, paste them into a text editor and save the file.
      </Step>
    </Steps>

    <Warning>
      The Console app may not capture lines written with `print`. When you are looking at a problem that only
      reproduces on a device, also write the lines through `os.Logger` inside `onDebugLog` to be safe.

      ```swift theme={null}
      import os
      let log = Logger(subsystem: "com.yourcompany.yourapp", category: "OneS1ght")
      OneS1ght.onDebugLog = { level, line in
          switch level {
          case .error: log.error("\(line, privacy: .public)")
          case .warn:  log.warning("\(line, privacy: .public)")
          default:     log.info("\(line, privacy: .public)")
          }
      }
      ```

      Put the subsystem (`com.yourcompany.yourapp`) into the Console app's filter.
    </Warning>
  </Tab>
</Tabs>

### Log levels

| Level    | Meaning                                                      |
| -------- | ------------------------------------------------------------ |
| `.log`   | Flow record — you don't normally need to read it             |
| `.info`  | Worth knowing — normal, but useful to notice                 |
| `.warn`  | Needs a look — not broken, but it won't behave as you expect |
| `.error` | Broken — that feature won't work until you fix it            |

When reporting a problem, **send everything — don't filter by level.** The flow right
before a failure is often what points to the cause.

## Android

**Coming soon.**
