root/Log-Dispatch-Config/trunk/t/03_reload.t

Revision 344 (checked in by miyagawa, 19 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 use strict;
2 use Test::More 'no_plan';
3
4 use Log::Dispatch::Config;
5 use FileHandle;
6 use File::Temp qw(tempfile);
7 use IO::Scalar;
8
9 sub writefile {
10     my $fh = FileHandle->new(">" . shift) or die $!;
11     $fh->print(@_);
12 }
13
14 my($fh, $file) = tempfile;
15 writefile($file, <<'CFG');
16 dispatchers=foo
17 foo.class=Log::Dispatch::File
18 foo.filename=/dev/null
19 foo.min_level=debug
20 CFG
21     ;
22
23 Log::Dispatch::Config->configure($file);
24
25 {
26     my $disp = Log::Dispatch->instance;
27     isa_ok $disp->{outputs}->{foo}, 'Log::Dispatch::File';
28
29     sleep 1;
30
31     writefile($file, <<'CFG');
32 dispatchers=bar
33 bar.class=Log::Dispatch::File
34 bar.filename=/dev/null
35 bar.min_level=debug
36 CFG
37     ;
38
39     local $SIG{__WARN__} = sub {};
40     my $disp2 = Log::Dispatch->instance;
41     isa_ok $disp2->{outputs}->{bar}, 'Log::Dispatch::File';
42     is $disp2->{outputs}->{foo}, undef;
43     isnt "$disp", "$disp2", "$disp - $disp2";
44 }
Note: See TracBrowser for help on using the browser.