Skip to content

Commit

Permalink
Allow users to specify stdout and stderr in Logging plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
abitofevrything committed Sep 16, 2023
1 parent 2aaa3f9 commit a56d01d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/src/plugin/logging.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -30,14 +30,27 @@ 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,
this.stackTraceLevel = Level.SEVERE,
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;

Expand Down

0 comments on commit a56d01d

Please sign in to comment.