root/trunk/plagger/t/core/log-level.t

Revision 1283 (checked in by miyagawa, 14 years ago)

config Filter now DWIMs in tests. Defaults to log:level = error and assets_path to the right directory, unless explicitly set in config. YAY for DRY!

Line 
1 use strict;
2 use t::TestPlagger;
3
4 plan 'no_plan';
5 run_eval_expected_with_capture;
6
7 package Plagger::Plugin::Test::Log;
8 use base qw( Plagger::Plugin );
9
10 sub register {
11     my($self, $context) = @_;
12     $self->log(error => "this is error");
13     $self->log(info  => "this is info");
14     $self->log(warn  => "this is warn");
15     $self->log(debug => "this is debug");
16 }
17
18 package main;
19
20 __END__
21
22 === log level is debug
23 --- input config
24 global:
25   log:
26     level: debug
27 plugins:
28   - module: Test::Log
29 --- expected
30 like $warning, qr/error/;
31 like $warning, qr/info/;
32 like $warning, qr/warn/;
33 like $warning, qr/debug/;
34
35 === info log level
36 --- input config
37 global:
38   log:
39     level: info
40 plugins:
41   - module: Test::Log
42 --- expected
43 like $warning, qr/error/;
44 like $warning, qr/info/;
45 unlike $warning, qr/warn/;
46 unlike $warning, qr/debug/;
Note: See TracBrowser for help on using the browser.