Skip to content

Commit

Permalink
adjust default logLevel configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
maticzav committed May 2, 2023
1 parent 29fa071 commit 76c02a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/SwiftGraphQLClient/Client/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ public class ClientConfiguration {
/// Logger that we use to communitcate state changes and events inside the client.
open var logger: Logger = Logger(label: "graphql.client")

public init() {}
public init() {
// Certain built-in exchanges (e.g. `DebugExchange`) product `.debug` logs that require `.debug` log level to be visible. This makes sure that the expected functionality of all exchanges matches the actual functionality (e.g. "debug exchange actually prints messages in the console").
self.logger.logLevel = .debug
}
}
10 changes: 10 additions & 0 deletions Sources/SwiftGraphQLClient/Exchanges/DebugExchange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import Foundation
import GraphQL

/// Exchange that logs operations going down- and results going up-stream.
///
/// - NOTE: `DebugExchange` assumes that the logger level of the client is set to `.debug`. Otherwise, the logs might not appear in the stream.
///
/// ```swift
/// // chaning the client logger level
/// var config = SwiftGraphQLClient.ClientConfiguration()
/// config.logger.logLevel = .debug
///
/// SwiftGraphQLClient.Client(request: request, exchanges: exchanges, config: config)
/// ```
public struct DebugExchange: Exchange {

/// Tells whether the client is in a development environment of not.
Expand Down

0 comments on commit 76c02a2

Please sign in to comment.