File: Configurator.pm

package info (click to toggle)
liblog-dispatch-config-perl 1.04-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 233; makefile: 2
file content (79 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (3)
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
71
72
73
74
75
76
77
78
79
package Log::Dispatch::Configurator;

use strict;
use vars qw($VERSION);
$VERSION = '1.00';

sub new {
    my($class, $file) = @_;
    bless { file   => $file }, $class;
}

sub myinit {
    my $self = shift;
    $self->{LDC_ctime} = 0 unless defined $self->{LDC_ctime};
    $self->{LDC_watch} = 0 unless defined $self->{LDC_watch};
}

sub reload { }

sub needs_reload {
    my $self = shift;
    return $self->{LDC_ctime} < (stat($self->{file}))[9];
}

sub should_watch {
    my $self = shift;
    $self->{LDC_watch} = shift if @_;
    return $self->{LDC_watch};
}

sub _abstract_method {
    require Carp;
    Carp::croak(shift, " is an abstract method of ", __PACKAGE__);
}

sub get_attrs_global { _abstract_method('get_attrs_global') }
sub get_attrs        { _abstract_method('get_attrs') }

1;
__END__

=head1 NAME

Log::Dispatch::Configurator - Abstract Configurator class

=head1 SYNOPSIS

  package Log::Dispatch::Configurator::Foo;
  use base qw(Log::Dispatch::Configurator);

  # should implement
  sub get_attrs_global { }
  sub get_attrs        { }

  # optional
  sub reload       { }
  sub needs_reload { }

=head1 DESCRIPTION

Log::Dispatch::Configurator is an abstract class of config parser. If
you make new configurator implementation, you should inherit from this
class.

See L<Log::Dispatch::Config/"PLUGGABLE CONFIGURATOR"> for details.

=head1 AUTHOR

Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>

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

=head1 SEE ALSO

L<Log::Dispatch::Config>

=cut