Commit | Line | Data |
8112b699 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Log::Contextual::SimpleLogger; |
5 | use Test::More 'no_plan'; |
6 | my $var_log; |
7 | my $var; |
8 | |
9 | my @levels = qw(debug trace warn info error fatal); |
10 | |
11 | BEGIN { |
12 | $var_log = Log::Contextual::SimpleLogger->new({ |
6ae293d7 |
13 | levels => [qw(trace debug info warn error fatal)], |
14 | coderef => sub { $var = shift } |
15 | }) |
8112b699 |
16 | } |
17 | |
18 | use Log::Contextual qw{ :log :dlog}, -logger => $var_log; |
19 | |
20 | my @args = qw(fizz buzz fizzbuzz); |
21 | |
22 | for my $level (@levels) { |
6ae293d7 |
23 | for my $prefix (qw(log logS Dlog DlogS)) { |
8112b699 |
24 | |
6ae293d7 |
25 | my $original = local $_ = "don't tread on me"; |
26 | my $method_name = "${prefix}_${level}"; |
27 | my $ref = __PACKAGE__->can($method_name) |
28 | or die "no ref found for method $method_name"; |
8112b699 |
29 | |
6ae293d7 |
30 | $ref->(sub { "$method_name" }, @args); |
31 | ok($_ eq $original, "\$_ was not disturbed by $method_name"); |
32 | ok($var eq "[$level] $method_name\n", "log argument was correct"); |
33 | } |
8112b699 |
34 | } |