summaryrefslogtreecommitdiffstats
path: root/t/003-errors.t
diff options
context:
space:
mode:
Diffstat (limited to 't/003-errors.t')
-rw-r--r--t/003-errors.t29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/003-errors.t b/t/003-errors.t
new file mode 100644
index 0000000..6c8cc03
--- /dev/null
+++ b/t/003-errors.t
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use lib 't/lib';
+use Test::More tests => 3;
+use Log::Dispatch::Channels;
+use Log::Dispatch::Null;
+
+my $logger = Log::Dispatch::Channels->new;
+for my $channel (1..3) {
+ $logger->add_channel($channel);
+ $logger->add(Log::Dispatch::Null->new(name => $channel,
+ min_level => 'debug'),
+ channels => $channel);
+}
+my $warnings = '';
+$SIG{__WARN__} = sub { $warnings .= $_[0] };
+$logger->add_channel(1);
+like($warnings, qr/^Channel 1 already exists!/,
+ "correct warning when replacing a channel");
+$warnings = '';
+$logger->add(Log::Dispatch::Null->new(name => 1, min_level => 'debug'));
+like($warnings, qr/^Output 1 already exists!/,
+ "correct warning when replacing an output");
+
+$warnings = '';
+$logger->log(channels => 4, message => 'test', level => 'debug');
+like($warnings, qr/^Channel 4 doesn't exist/,
+ "correct warning when forwarding to a nonexistant channel");