|
From: Roland B. <rol...@ff...> - 2003-09-29 21:19:36
|
On Fri, 26 Sep 2003 23:15:36 -0700 Mike Schilli <msc...@ao...> wrote:
MS> Roland Bauer wrote:
MS>
MS> > The following patch will make "$ENV{HOME}/log4perl.conf"
MS> > the default file for the init method if it is called
MS> > without parameters. What do you think about having a default
MS> > config file?
MS>
MS> Hmm, Kevin and I talked about this a bit, turns out that $ENV{HOME}
MS> isn't portable (Win32, Mac?). Also, I don't think log4j has anything
MS> like this (probably for the same reason). And it's no hassle to write
MS> init("$ENV{HOME}/log4perl.conf") if you really want this file name as
MS> a
MS> default -- so, sorry, I'd rather leave that up to the application to
MS> decide. Hope that's ok with you -- but keep the suggestions coming! :)
You are right, $ENV{HOME} is not portable, however, many CPAN modules
rely on that so the Windows people have to cope with this situation and
there are attempts to give a solution, e. g. some CPAN-Modules
- User
- File::HomeDir
BTW, the lack of some environment variables in Windows is a big problem
and I'd really liked a portable Perl solution. Maybe a module
Env::Portable with Env::Portable::Win32, ... (like File::Spec).
If I wrote init("$ENV{HOME}/log4perl.conf") this would be portable neither.
It would be just *my* modules fault instead of Log4perl's fault ;-)
Maybe the default mechanism with $ENV{HOME} could be supported if
and only if $ENV{HOME} is defined?
Another suggestion were to support an environment variable which keeps
the name of the default config file (see my posting from Sun, 21 Sep 2003):
>From http://jakarta.apache.org/log4j/docs/manual.html:
>"In case the system property log4j.configuration is not defined,
>then set the string variable resource to its
>default value "log4j.properties"."
Maybe $ENV{log4j_configuration}? $ENV{LOG4PERL_CONFIGURATION}?
It could be easily implemented. However, as you pointed out, it's
an important conceptual decision what defaults should be supported and
in what way. The question is how Java system properties can/should be
supported in Perl.
What do you think about my second wish (from posting mentioned before):
>2) Is the function easy_init really necessary? Or - at least - could
>init accept the same parameters?
>
>The following syntax seems ok:
>
>init($filename);
>init(\$config_text);
>init(\%key_value_pairs);
>init($url);
>
>easy_init($ERROR); # where the string contains a number
>easy_init(\%key_value_pairs);
>easy_init(\%key_value_pairs_1, \%key_value_pairs_2, ...);
>
>If I am switching from
>"easy" usage to "standard" usage, I have to
>a) remove ':easy'
>b) change easy_init to init
>c) have to supply a config file name
>
>I'd like to omit step b) and c) ;-)
>
>Summary:
>- the call of init without parameters should be ok (a default config
> file should be searched
>- importing ':easy' should signal that the user wants "easy" usage
>- init should accept $DEBUG, ... as parameters (if ":easy" has been imported)
Thanks for your patience ;-)
Roland
|