Logging
Let us know how we can improve our documentation:
By default logs are disabled.
You can enable it for requests and/or websocket events with different log levels (.error
, .debug
, .info
).
Client.configureShared(.init(apiKey: <#API KEY#>, logOptions: .info))
⚠️ Using
.info
and.debug
levels for production builds are not recommended.
Options
-
🐴 for REST requests:
-
.requestsError
— errors only -
.requests
— for debugging -
.requestsInfo
— all logs with JSON's
-
-
🦄 for web socket events:
-
.webSocketError
-
.webSocket
-
.webSocketInfo
-
-
🗞 for notifications:
-
.notificationsError
-
.notifications
-
-
💽 for a database (in development):
-
.databaseError
-
.database
-
.databaseInfo
-
-
for all error logs:
.error
-
for all debugging logs:
.debug
-
full logs:
.info
Examples:
-
Only errors:
Client.configureShared(.init(apiKey: <#API KEY#>, logOptions: .error))
-
Full websocket events (with JSON's) and debug requests logs:
Client.configureShared(.init(apiKey: <#API KEY#>,
logOptions: [.requests, .webSocketInfo]))
-
Only requests logs with JSON's:
Client.configureShared(.init(apiKey: <#API KEY#>, logOptions: .requestsInfo))
Custom log function
You can replace the logging function with a custom one instead of printing to the console.
ClientLogger.logger = { icon, dateTime, message in
CustomLogger.log("\(icon) [\(dateTime)] \(message)")
}