Skip to content

Commit

Permalink
Move logging when connecting
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexedia committed Nov 1, 2024
1 parent 5d60dcc commit cccf3b8
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ abstract class Nyxx {

/// Create an instance of [NyxxRest] using the provided options.
static Future<NyxxRest> connectRestWithOptions(RestApiOptions apiOptions, [RestClientOptions clientOptions = const RestClientOptions()]) async {
clientOptions.logger
..info('Connecting to the REST API')
..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}')
..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}');

return _doConnect(apiOptions, clientOptions, () async {
clientOptions.logger
..info('Connecting to the REST API')
..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}')
..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}');

final client = NyxxRest._(apiOptions, clientOptions);

return client
Expand All @@ -111,12 +111,12 @@ abstract class Nyxx {
///
/// Note that `client.user.id` will contain [Snowflake.zero] if there no `identify` scope.
static Future<NyxxOAuth2> connectOAuth2WithOptions(OAuth2ApiOptions apiOptions, [RestClientOptions clientOptions = const RestClientOptions()]) async {
clientOptions.logger
..info('Connecting to the REST API via OAuth2')
..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}')
..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}');

return _doConnect(apiOptions, clientOptions, () async {
clientOptions.logger
..info('Connecting to the REST API via OAuth2')
..fine('Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent}')
..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}');

final client = NyxxOAuth2._(apiOptions, clientOptions);
final information = await client.users.fetchCurrentOAuth2Information();

Expand All @@ -136,16 +136,16 @@ abstract class Nyxx {
GatewayApiOptions apiOptions, [
GatewayClientOptions clientOptions = const GatewayClientOptions(),
]) async {
clientOptions.logger
..info('Connecting to the Gateway API')
..fine(
'Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent},'
' Intents: ${apiOptions.intents.value}, Payloads: ${apiOptions.payloadFormat.value}, Compression: ${apiOptions.compression.name},'
' Shards: ${apiOptions.shards?.join(', ')}, Total shards: ${apiOptions.totalShards}, Large threshold: ${apiOptions.largeThreshold}',
)
..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}');

return _doConnect(apiOptions, clientOptions, () async {
clientOptions.logger
..info('Connecting to the Gateway API')
..fine(
'Token: ${apiOptions.token}, Authorization: ${apiOptions.authorizationHeader}, User-Agent: ${apiOptions.userAgent},'
' Intents: ${apiOptions.intents.value}, Payloads: ${apiOptions.payloadFormat.value}, Compression: ${apiOptions.compression.name},'
' Shards: ${apiOptions.shards?.join(', ')}, Total shards: ${apiOptions.totalShards}, Large threshold: ${apiOptions.largeThreshold}',
)
..fine('Plugins: ${clientOptions.plugins.map((plugin) => plugin.name).join(', ')}');

final client = NyxxGateway._(apiOptions, clientOptions);

client
Expand Down

0 comments on commit cccf3b8

Please sign in to comment.