Debug
Debug output is silent by default. A user can activate it with:
use API::Discord::Debug;
Any module that want to output to $*STDERR can do so with:
use API::Discord::Debug <FROM-MODULE>
The subs debug-print
and debug-say
forward arguments to $*ERR.print
and $*ERR.say
.
Debug output can be diverted to Supply
s of Str
with mixin roles for
filtering.
use API::Discord::Debug;
react whenever debug-say().merge(debug-print()) {
when HEARTBEAT { $*ERR.print: $_ }
when CONNECTION { note now.Datetime.Str, ' ', $_ }
when /your term here/ { .&do-stuff() }
default {}
}
The sub debug-say-logfile
diverts output to a IO::Path
and forwards named
arguments to IO::Handle.open
.
use API::Discord::Debug;
debug-say-logfile('/tmp/discord-bot-logfile.txt', :append);
react whenever debug-print() {
default {}
}