.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Log::Handler::Config 3pm" .TH Log::Handler::Config 3pm "2014-10-24" "perl v5.20.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Log::Handler::Config \- The main config loader. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Log::Handler; \& \& my $log = Log::Handler\->new(); \& \& # Config::General \& $log\->config(config => \*(Aqfile.conf\*(Aq); \& \& # Config::Properties \& $log\->config(config => \*(Aqfile.props\*(Aq); \& \& # YAML \& $log\->config(config => \*(Aqfile.yaml\*(Aq); .Ve .PP Or .PP .Vb 1 \& use Log::Handler; \& \& my $log = Log::Handler\->new(); \& \& $log\->config( \& config => \*(Aqfile.conf\*(Aq \& plugin => \*(AqYAML\*(Aq, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module makes it possible to load the configuration from a file. The configuration type is determined by the file extension. It's also possible to mix file extensions with another configuration types. .SH "PLUGINS" .IX Header "PLUGINS" .Vb 5 \& Plugin name File extensions \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& Config::General cfg, conf \& Config::Properties props, jcfg, jconf \& YAML yml, yaml .Ve .PP If the extension is not defined then \f(CW\*(C`Config::General\*(C'\fR is used by default. .SH "METHODS" .IX Header "METHODS" .SS "\fIconfig()\fP" .IX Subsection "config()" With this method it's possible to load the configuration for your outputs. .PP The following options are valid: .IP "\fBconfig\fR" 4 .IX Item "config" With this option you can pass a file name or the configuration as a hash reference. .Sp .Vb 3 \& $log\->config(config => \*(Aqfile.conf\*(Aq); \& # or \& $log\->config(config => \e%config); .Ve .IP "\fBplugin\fR" 4 .IX Item "plugin" With this option it's possible to say which plugin you want to use. Maybe you want to use the file extension \f(CW\*(C`conf\*(C'\fR with \f(CW\*(C`YAML\*(C'\fR, which is reserved for the plugin \f(CW\*(C`Config::General\*(C'\fR. .Sp Examples: .Sp .Vb 4 \& # this would use Config::General \& $log\->config( \& config => \*(Aqfile.conf\*(Aq \& ); \& \& # this would force .conf with YAML \& $log\->config( \& config => \*(Aqfile.conf\*(Aq, \& plugin => \*(AqYAML\*(Aq \& ); .Ve .IP "\fBsection\fR" 4 .IX Item "section" If you want to write the configuration into a global configuration file then you can create a own section for the logger: .Sp .Vb 6 \& \& \& filename = file.log \& minlevel = emerg \& maxlevel = warning \& \& \& \& minlevel = emerg \& maxlevel = debug \& \& \& \& \& foo = bar \& bar = baz \& baz = foo \& .Ve .Sp Now your configuration is placed in the \f(CW\*(C`logger\*(C'\fR section. You can load this section with .Sp .Vb 4 \& $log\->config( \& config => \*(Aqfile.conf\*(Aq, \& section => \*(Aqlogger\*(Aq, \& ); \& \& # or if you load the configuration yourself to %config \& \& $log\->config( \& config => \e%config, \& section => \*(Aqlogger\*(Aq, \& ); \& \& # or just \& \& $log\->config( config => $config{logger} ); .Ve .SH "PLUGINS" .IX Header "PLUGINS" .Vb 3 \& Config::General \- inspired by the well known apache config format \& Config::Properties \- Java\-style property files \& YAML \- optimized for human readability .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" .SS "Config structures" .IX Subsection "Config structures" A very simple configuration looks like: .PP .Vb 10 \& $log\->config(config => { \& file => { \& alias => \*(Aqfile1\*(Aq, \& filename => \*(Aqfile1.log\*(Aq, \& maxlevel => \*(Aqinfo\*(Aq, \& minlevel => \*(Aqwarn\*(Aq, \& }, \& screen => { \& alias => \*(Aqscreen1\*(Aq, \& maxlevel => \*(Aqdebug\*(Aq, \& minlevel => \*(Aqemerg\*(Aq, \& } \& }); .Ve .PP Now, if you want to add another file-output then you can pass the outputs with a array reference: .PP .Vb 10 \& $log\->config(config => { \& file => [ \& { \& alias => \*(Aqfile1, \& filename => \*(Aqfile1.log\*(Aq, \& maxlevel => \*(Aqinfo\*(Aq, \& minlevel => \*(Aqwarn\*(Aq, \& }, \& { \& alias => \*(Aqfile2\*(Aq, \& filename => \*(Aqfile2.log\*(Aq, \& maxlevel => \*(Aqerror\*(Aq, \& minlevel => \*(Aqemergency\*(Aq, \& } \& ], \& screen => { \& alias => \*(Aqscreen1\*(Aq, \& maxlevel => \*(Aqdebug\*(Aq, \& minlevel => \*(Aqemerg\*(Aq, \& }, \& }); .Ve .PP It's also possible to pass the outputs as a hash reference. The hash keys \*(L"file1\*(R" and \*(L"file2\*(R" will be used as aliases. .PP .Vb 10 \& $log\->config(config => { \& file => { \& file1 => { \& filename => \*(Aqfile1.log\*(Aq, \& maxlevel => \*(Aqinfo\*(Aq, \& minlevel => \*(Aqwarn\*(Aq, \& }, \& file2 => { \& filename => \*(Aqfile2.log\*(Aq, \& maxlevel => \*(Aqerror\*(Aq, \& minlevel => \*(Aqemergency\*(Aq, \& } \& }, \& screen => { \& alias => \*(Aqscreen1\*(Aq, \& maxlevel => \*(Aqdebug\*(Aq, \& minlevel => \*(Aqemerg\*(Aq, \& }, \& }); .Ve .PP If you pass the configuration with the alias as a hash key then it's also possible to pass a section called \*(L"default\*(R". The options from this section will be used as defaults. .PP .Vb 10 \& $log\->config(config => { \& file => { \& default => { # defaults for all file\-outputs \& mode => \*(Aqappend\*(Aq, \& }, \& file1 => { \& filename => \*(Aqfile1.log\*(Aq, \& maxlevel => \*(Aqinfo\*(Aq, \& minlevel => \*(Aqwarn\*(Aq, \& }, \& file2 => { \& filename => \*(Aqfile2.log\*(Aq, \& maxlevel => \*(Aqerror\*(Aq, \& minlevel => \*(Aqemergency\*(Aq, \& } \& }, \& screen => { \& alias => \*(Aqscreen1\*(Aq, \& maxlevel => \*(Aqdebug\*(Aq, \& minlevel => \*(Aqemerg\*(Aq, \& }, \& }); .Ve .SS "Examples for the config plugins" .IX Subsection "Examples for the config plugins" \fIConfig::General\fR .IX Subsection "Config::General" .PP .Vb 10 \& \& alias = file1 \& fileopen = 1 \& reopen = 1 \& permissions = 0640 \& maxlevel = info \& minlevel = warn \& mode = append \& timeformat = %b %d %H:%M:%S \& debug_mode = 2 \& filename = example.log \& message_layout = \*(Aq%T %H[%P] [%L] %S: %m\*(Aq \& .Ve .PP Or .PP .Vb 10 \& \& \& fileopen = 1 \& reopen = 1 \& permissions = 0640 \& maxlevel = info \& minlevel = warn \& mode = append \& timeformat = %b %d %H:%M:%S \& debug_mode = 2 \& filename = example.log \& message_layout = \*(Aq%T %H[%P] [%L] %S: %m\*(Aq \& \& .Ve .PP \fI\s-1YAML\s0\fR .IX Subsection "YAML" .PP .Vb 10 \& \-\-\- \& file: \& alias: file1 \& debug_mode: 2 \& filename: example.log \& fileopen: 1 \& maxlevel: info \& minlevel: warn \& mode: append \& permissions: 0640 \& message_layout: \*(Aq%T %H[%P] [%L] %S: %m\*(Aq \& reopen: 1 \& timeformat: \*(Aq%b %d %H:%M:%S\*(Aq .Ve .PP Or .PP .Vb 10 \& \-\-\- \& file: \& file1: \& debug_mode: 2 \& filename: example.log \& fileopen: 1 \& maxlevel: info \& minlevel: warn \& mode: append \& permissions: 0640 \& message_layout: \*(Aq%T %H[%P] [%L] %S: %m\*(Aq \& reopen: 1 \& timeformat: \*(Aq%b %d %H:%M:%S\*(Aq .Ve .PP \fIConfig::Properties\fR .IX Subsection "Config::Properties" .PP .Vb 11 \& file.alias = file1 \& file.reopen = 1 \& file.fileopen = 1 \& file.maxlevel = info \& file.minlevel = warn \& file.permissions = 0640 \& file.mode = append \& file.timeformat = %b %d %H:%M:%S \& file.debug_mode = 2 \& file.filename = example.log \& file.message_layout = \*(Aq%T %H[%P] [%L] %S: %m\*(Aq .Ve .PP Or .PP .Vb 11 \& file.file1.alias = file1 \& file.file1.reopen = 1 \& file.file1.fileopen = 1 \& file.file1.maxlevel = info \& file.file1.minlevel = warn \& file.file1.permissions = 0640 \& file.file1.mode = append \& file.file1.timeformat = %b %d %H:%M:%S \& file.file1.debug_mode = 2 \& file.file1.filename = example.log \& file.file1.message_layout = \*(Aq%T %H[%P] [%L] %S: %m\*(Aq .Ve .SH "PREREQUISITES" .IX Header "PREREQUISITES" .Vb 2 \& Carp \& Params::Validate .Ve .SH "EXPORTS" .IX Header "EXPORTS" No exports. .SH "REPORT BUGS" .IX Header "REPORT BUGS" Please report all bugs to . .PP If you send me a mail then add Log::Handler into the subject. .SH "AUTHOR" .IX Header "AUTHOR" Jonny Schulz . .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2007\-2009 by Jonny Schulz. All rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.