Skip to content

Commit 5608579

Browse files
authored
Add documentation about intercepting logs (#3017)
1 parent b70c3e4 commit 5608579

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

docusaurus/docs/iOS/basics/logs.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ We have four different `logLevel`'s available.
2525
- `.warning` (This will surface all warnings to the console).
2626
- `.error` (This will surface all error logs).
2727

28+
## Filtering Logs
29+
30+
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:
31+
32+
```swift
33+
import StreamChat
34+
35+
// Only one subsystem
36+
LogConfig.subsystems = .httpRequests
37+
// Multiple subsystems
38+
LogConfig.subsystems = [.httpRequests, .authentication]
39+
```
40+
41+
We have the following subsystems available.
42+
43+
- `.all` (The default, this will log all subsystems available).
44+
- `.database` (The subsystem responsible for database operations).
45+
- `.httpRequests` (The subsystem responsible for HTTP operations).
46+
- `.webSocket` (The subsystem responsible for WebSocket operations).
47+
- `.offlineSupport` (The subsystem responsible for offline support).
48+
- `.authentication` (The subsystem responsible for authentication).
49+
- `.audioPlayback` (The subsystem responsible for audio playback).
50+
- `.audioRecording` (The subsystem responsible for audio recording).
51+
- `.other` (This is the subsystem related to misc logs and not related to any subsystem).
52+
2853
## Customizing Logs
2954

3055
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.
@@ -45,4 +70,30 @@ LogConfig.showDate = false
4570
LogConfig.showFunctionName = false
4671
```
4772

48-
Here, you're hiding the `threadName`, `date` and `functionName`.
73+
Here, you're hiding the `threadName`, `date` and `functionName` from the log.
74+
75+
## Intercepting Logs
76+
77+
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.
78+
79+
The way you do this is by creating a custom log destination.
80+
81+
```swift
82+
class CustomLogDestination: BaseLogDestination {
83+
override func process(logDetails: LogDetails) {
84+
let level = logDetails.level
85+
let message = logDetails.message
86+
// Send the log details to your server or third-party SDK
87+
...
88+
}
89+
}
90+
```
91+
92+
Make sure that you set the log destination before initialising the Stream Chat SDK:
93+
94+
```swift
95+
LogConfig.destinationTypes = [
96+
ConsoleLogDestination.self,
97+
CustomLogDestination.self // Your custom destination
98+
]
99+
```

0 commit comments

Comments
 (0)