File: 10_caller.t

package info (click to toggle)
liblog-dispatch-config-perl 1.04-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 224 kB
  • sloc: perl: 233; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use strict;
use Test::More tests => 2;

use FileHandle;

sub slurp {
    my $fh = FileHandle->new(shift) or die $!;
    local $/;
    return $fh->getline;
}

use Log::Dispatch::Config;
Log::Dispatch::Config->configure('t/log.cfg');

sub logit {
    my $disp = Log::Dispatch::Config->instance;
    $disp->debug(@_);
}

logit "foobar";
like slurp("t/log.out"), qr/foobar at .*10_caller\.t line 17/;

local $Log::Dispatch::Config::CallerDepth = 1;
logit "bazbaz";
like slurp("t/log.out"), qr/bazbaz at .*10_caller\.t line 24/;

END { unlink 't/log.out' if -e 't/log.out' }