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

SEE ALSO

103       Log::Log4perl::Config::PropertyConfigurator
104
105       Log::Log4perl::Config::DOMConfigurator
106
107       Log::Log4perl::Config::LDAPConfigurator (tbd!)
108
110       Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess
111       <cpan@goess.org>.
112
113       This library is free software; you can redistribute it and/or modify it
114       under the same terms as Perl itself.
115
116
117
118perl v5.12.2                      2010-08-31       Config::BaseConfigurator(3)
Impressum