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() method
50           will return a reference to an array of configuration text lines.
51           This will typically be used by the parse() method to process the
52           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 hashes
62           (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

LICENSE

110       Copyright 2002-2013 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

AUTHOR

117       Please contribute patches to the project on Github:
118
119           http://github.com/mschilli/log4perl
120
121       Send bug reports or requests for enhancements to the authors via our
122
123       MAILING LIST (questions, bug reports, suggestions/patches):
124       log4perl-devel@lists.sourceforge.net
125
126       Authors (please contact them via the list above, not directly): Mike
127       Schilli <m@perlmeister.com>, Kevin Goess <cpan@goess.org>
128
129       Contributors (in alphabetical order): Ateeq Altaf, Cory Bennett, Jens
130       Berthold, Jeremy Bopp, Hutton Davidson, Chris R. Donnelly, Matisse
131       Enzer, Hugh Esco, Anthony Foiani, James FitzGibbon, Carl Franks, Dennis
132       Gregorovic, Andy Grundman, Paul Harrington, Alexander Hartmaier  David
133       Hull, Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
134       Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope, Lars
135       Thegler, David Viner, Mac Yang.
136
137
138
139perl v5.36.0                      2023-01-20       Config::BaseConfigurator(3)
Impressum