File: trace_custom.t

package info (click to toggle)
liblog-trace-perl 1.070-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 180 kB
  • ctags: 42
  • sloc: perl: 859; makefile: 44
file content (31 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (4)
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
28
29
30
31
#!/usr/local/bin/perl -w
# $Id: trace_custom.t,v 1.3 2004/11/23 14:07:31 simonf Exp $
use strict;
use Test::More tests => 4;

# Find local libs unless running under Test::Harness
BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' unless grep /\bblib\b/, @INC }
require_ok('Log::Trace');

my $output;
my $trace = sub {
    $output = shift() . "\n";
};

my $message;
import Log::Trace custom => $trace;
$message = 'sending trace message to custom subroutine';
TRACE($message);
is ($output, "$message\n", 'message handled by custom tracing routine');

$output = '';
import Log::Trace custom => $trace, {Level => 1};
$message = $0;
TRACE({Level => 1}, $message);
is ($output, "$message\n", 'level 1 appended sent to custom handler');

$output = '';
TRACE({Level => 99}, $message);
is ($output, '', 'level 99 message not traced ok');

sub TRACE {}