1Config::BaseConfiguratoUrs(e3r)Contributed Perl DocumentCaotnifoing::BaseConfigurator(3)
2
3
4

NAME

6       Log::Log4perl::Config::BaseConfigurator - Configurator Base Class
7

SYNOPSIS

9       This is a virtual base class, all configurators should be derived from
10       it.
11

DESCRIPTION

13       METHODS
14
15       "new"
16           Constructor, typically called like
17
18               my $config_parser = SomeConfigParser->new(
19                   file => $file,
20               );
21
22               my $data = $config_parser->parse();
23
24           Instead of "file", the derived class "SomeConfigParser" may define
25           any type of configuration input medium (e.g. "url => 'http://foo
26           bar'").  It just has to make sure its "parse()" method will later
27           pull the input data from the medium specified.
28
29           The base class accepts a filename or a reference to an array of
30           text lines:
31
32           "file"
33               Specifies a file which the "parse()" method later parses.
34
35           "text"
36               Specifies a reference to an array of scalars, representing con‐
37               figuration records (typically lines of a file). Also accepts a
38               simple scalar, which it splits at its newlines and transforms
39               it into an array:
40
41                   my $config_parser = MyYAMLParser->new(
42                       text => ['foo: bar',
43                                'baz: bam',
44                               ],
45                   );
46
47                   my $data = $config_parser->parse();
48
49           If either "file" or "text" parameters have been specified in the
50           constructor call, a later call to the configurator's "text()"
51           method will return a reference to an array of configuration text
52           lines.  This will typically be used by the "parse()" method to
53           process the input.
54
55       "parse"
56           Virtual method, needs to be defined by the derived class.
57
58       Parser requirements
59
60       ·   If the parser provides variable substitution functionality, it has
61           to implement it.
62
63       ·   The parser's "parse()" method returns a reference to a hash of
64           hashes (HoH).  The top-most hash contains the top-level keywords
65           ("category", "appender") as keys, associated with values which are
66           references to more deeply nested hashes.
67
68       ·   The "log4perl." prefix (e.g. as used in the PropertyConfigurator
69           class) is stripped, it's not part in the HoH structure.
70
71       ·   Each Log4perl config value is indicated by the "value" key, as in
72
73               $data->{category}->{Bar}->{Twix}->{value} = "WARN, Logfile"
74
75       EXAMPLES
76
77       The following Log::Log4perl configuration:
78
79           log4perl.category.Bar.Twix        = WARN, Screen
80           log4perl.appender.Screen          = Log::Log4perl::Appender::File
81           log4perl.appender.Screen.filename = test.log
82           log4perl.appender.Screen.layout   = Log::Log4perl::Layout::SimpleLayout
83
84       needs to be transformed by the parser's "parse()" method into this data
85       structure:
86
87           { appender => {
88               Screen  => {
89                 layout => {
90                   value  => "Log::Log4perl::Layout::SimpleLayout" },
91                   value  => "Log::Log4perl::Appender::Screen",
92               },
93             },
94             category => {
95               Bar => {
96                 Twix => {
97                   value => "WARN, Screen" }
98               } }
99           }
100
101       For a full-fledged example, check out the sample YAML parser implemen‐
102       tation in "eg/yamlparser". It uses a simple YAML syntax to specify the
103       Log4perl configuration to illustrate the concept.
104

SEE ALSO

106       Log::Log4perl::Config::PropertyConfigurator
107
108       Log::Log4perl::Config::DOMConfigurator
109
110       Log::Log4perl::Config::LDAPConfigurator (tbd!)
111

AUTHOR

113       Mike Schilli, <m@perlmeister.com>, 2004 Kevin Goess, <cpan@goess.org>
114       Jan-2003
115
116
117
118perl v5.8.8                       2002-07-10       Config::BaseConfigurator(3)
Impressum