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;