diff --git a/README.md b/README.md index 3efffa197..21947bbf4 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ If you're already familiar with Discord's API, here's a quick example to get you import 'package:nyxx/nyxx.dart'; void main() async { - final client = await Nyxx.connectWebsocket('', GatewayIntents.allUnprivileged); + final client = await Nyxx.connectGateway('', GatewayIntents.allUnprivileged); final botUser = await client.users.fetchCurrentUser(); diff --git a/lib/src/plugin/logging.dart b/lib/src/plugin/logging.dart index c2dd7497d..a2ce512a2 100644 --- a/lib/src/plugin/logging.dart +++ b/lib/src/plugin/logging.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'dart:io'; +import 'dart:io' as io; import 'package:logging/logging.dart'; import 'package:nyxx/src/api_options.dart'; @@ -30,6 +30,16 @@ class Logging extends NyxxPlugin { /// Whether to censor the token of clients this plugin is attached to. final bool censorToken; + /// The sink normal messages are sent to. + /// + /// Defaults to [io.stdout]. + final StringSink stdout; + + /// The sink error messages are sent to. + /// + /// Defaults to [io.stderr]. + final StringSink stderr; + /// Create a new instance of the [Logging] plugin. Logging({ this.stderrLevel = Level.WARNING, @@ -37,7 +47,10 @@ class Logging extends NyxxPlugin { this.logLevel = Level.INFO, this.truncateLogsAt = 1000, this.censorToken = true, - }); + StringSink? stdout, + StringSink? stderr, + }) : stdout = stdout ?? io.stdout, + stderr = stderr ?? io.stderr; static int _clients = 0;