File: filter_caller.pl

package info (click to toggle)
liblog-handler-perl 0.90-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 576 kB
  • sloc: perl: 2,758; makefile: 4
file content (70 lines) | stat: -rw-r----- 1,262 bytes parent folder | download | duplicates (6)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl

=head1 AUTHOR

Jonny Schulz <jschulz.cpan(at)bloonix.de>

=head1 DESCRIPTION

This script shows you examples how you can filter
messages from different callers.

=head1 POWERED BY

     _    __ _____ _____ __  __ __ __   __
    | |__|  |     |     |  \|  |__|\  \/  /
    |  . |  |  |  |  |  |      |  | >    <
    |____|__|_____|_____|__|\__|__|/__/\__\

=head1 COPYRIGHT

Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=cut

use strict;
use warnings;
use Log::Handler;

my $log = Log::Handler->new();

$log->add(
    screen => {
        maxlevel => 'info',
        newline  => 1,
        message_layout => '%L - (filter:foo) %m',
        filter_caller  => 'foo',
    }
);

$log->add(
    screen => {
        maxlevel => 'info',
        newline  => 1,
        message_layout => '%L - (filter:bar) %m',
        filter_caller  => 'bar',
    }
);

$log->add(
    screen => {
        maxlevel => 'info',
        newline  => 1,
        message_layout => '%L - (except:baz) %m',
        except_caller  => 'baz',
    }
);

package foo;
$log->info('foo');

package bar;
$log->info('bar');

package baz;
$log->info('baz');

1;