Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion docusaurus/docs/iOS/basics/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,31 @@ We have four different `logLevel`'s available.
- `.warning` (This will surface all warnings to the console).
- `.error` (This will surface all error logs).

## Filtering Logs

In case you are debugging a specific area of the SDK, you can filter the logs based on subsystems. You can select one or multiple subsystems:

```swift
import StreamChat

// Only one subsystem
LogConfig.subsystems = .httpRequests
// Multiple subsystems
LogConfig.subsystems = [.httpRequests, .authentication]
```

We have the following subsystems available.

- `.all` (The default, this will log all subsystems available).
- `.database` (The subsystem responsible for database operations).
- `.httpRequests` (The subsystem responsible for HTTP operations).
- `.webSocket` (The subsystem responsible for WebSocket operations).
- `.offlineSupport` (The subsystem responsible for offline support).
- `.authentication` (The subsystem responsible for authentication).
- `.audioPlayback` (The subsystem responsible for audio playback).
- `.audioRecording` (The subsystem responsible for audio recording).
- `.other` (This is the subsystem related to misc logs and not related to any subsystem).

## Customizing Logs

By default, the logs will provide basic text to your console. Still, in the SDK, we have functionality that enables you to provide custom Emoji's to identify logs coming from the SDK quickly.
Expand All @@ -45,4 +70,30 @@ LogConfig.showDate = false
LogConfig.showFunctionName = false
```

Here, you're hiding the `threadName`, `date` and `functionName`.
Here, you're hiding the `threadName`, `date` and `functionName` from the log.

## Intercepting Logs

You can also intercept logs from the SDK so that you can send the data to your own servers or any other third-party analytics provider.

The way you do this is by creating a custom log destination.

```swift
class CustomLogDestination: BaseLogDestination {
override func process(logDetails: LogDetails) {
let level = logDetails.level
let message = logDetails.message
// Send the log details to your server or third-party SDK
...
}
}
```

Make sure that you set the log destination before initialising the Stream Chat SDK:

```swift
LogConfig.destinationTypes = [
ConsoleLogDestination.self,
CustomLogDestination.self // Your custom destination
]
```