root/Log-Dispatch-Config/trunk/lib/Log/Dispatch/Configurator.pm

Revision 528 (checked in by miyagawa, 19 years ago)

doc

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 package Log::Dispatch::Configurator;
2
3 use strict;
4 use vars qw($VERSION);
5 $VERSION = 0.12;
6
7 sub new {
8     my($class, $file) = @_;
9     bless { file   => $file }, $class;
10 }
11
12 sub myinit {
13     my $self = shift;
14     $self->{LDC_ctime} = 0 unless defined $self->{LDC_ctime};
15     $self->{LDC_watch} = 0 unless defined $self->{LDC_watch};
16 }
17
18 sub reload { }
19
20 sub needs_reload {
21     my $self = shift;
22     return $self->{LDC_ctime} < (stat($self->{file}))[9];
23 }
24
25 sub should_watch {
26     my $self = shift;
27     $self->{LDC_watch} = shift if @_;
28     return $self->{LDC_watch};
29 }
30
31 sub _abstract_method {
32     require Carp;
33     Carp::croak(shift, " is an abstract method of ", __PACKAGE__);
34 }
35
36 sub get_attrs_global { _abstract_method('get_attrs_global') }
37 sub get_attrs        { _abstract_method('get_attrs') }
38
39 1;
40 __END__
41
42 =head1 NAME
43
44 Log::Dispatch::Configurator - Abstract Configurator class
45
46 =head1 SYNOPSIS
47
48   package Log::Dispatch::Configurator::Foo;
49   use base qw(Log::Dispatch::Configurator);
50
51   # should implement
52   sub get_attrs_global { }
53   sub get_attrs        { }
54
55   # optional
56   sub reload       { }
57   sub needs_reload { }
58
59 =head1 DESCRIPTION
60
61 Log::Dispatch::Configurator is an abstract class of config parser. If
62 you make new configurator implementation, you should inherit from this
63 class.
64
65 See L<Log::Dispatch::Config/"PLUGGABLE CONFIGURATOR"> for details.
66
67 =head1 AUTHOR
68
69 Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
70
71 This library is free software; you can redistribute it and/or modify
72 it under the same terms as Perl itself.
73
74 =head1 SEE ALSO
75
76 L<Log::Dispatch::Config>
77
78 =cut
79
Note: See TracBrowser for help on using the browser.