root/Log-Dispatch-Config/trunk/t/02_log.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 IO::Scalar;
7
8 sub slurp {
9     my $fh = FileHandle->new(shift) or die $!;
10     local $/;
11     return $fh->getline;
12 }
13
14 my $log;
15 BEGIN { $log = 't/log.out'; unlink $log if -e $log }
16 END   { unlink $log if -e $log }
17
18 Log::Dispatch::Config->configure('t/log.cfg');
19
20 tie *STDERR, 'IO::Scalar', \my $err;
21
22 my $disp = Log::Dispatch->instance;
23 $disp->debug('debug');
24 $disp->alert('alert');
25
26 untie *STDERR;
27
28 my $file = slurp $log;
29 like $file, qr(debug at t/02_log\.t), 'debug';
30 like $file, qr(alert at t/02_log\.t), 'alert';
31
32 ok $err !~ qr/debug/, 'no debug';
33 is $err, "alert", 'alert';
34
35
36
Note: See TracBrowser for help on using the browser.