From: Roland B. <rol...@ff...> - 2003-09-25 21:28:15
|
The following patch will make "$ENV{HOME}/log4perl.conf" the default file for the init method if it is called without parameters. What do you think about having a default config file? - Roland #------------------------------------- --- Config.pm_org Mon Aug 11 07:03:28 2003 +++ Config.pm Thu Sep 25 23:07:31 2003 @@ -495,6 +495,12 @@ $res->message." "; } }else{ + unless (defined $config) { + my $default = "$ENV{HOME}/log4perl.conf"; + # BETTER: + # my $default = catfile($ENV{HOME} || die, 'log4perl.conf'); + $config = $default if -f $default; + } open FILE, "<$config" or die "Cannot open config file '$config'"; @text = <FILE>; close FILE; #------------------------------------- -- Roland Bauer http://www.fff.at/contact/ |
From: Mike S. <msc...@ao...> - 2003-09-27 06:18:18
|
Roland Bauer wrote: > The following patch will make "$ENV{HOME}/log4perl.conf" > the default file for the init method if it is called > without parameters. What do you think about having a default > config file? Hmm, Kevin and I talked about this a bit, turns out that $ENV{HOME} isn't portable (Win32, Mac?). Also, I don't think log4j has anything like this (probably for the same reason). And it's no hassle to write init("$ENV{HOME}/log4perl.conf") if you really want this file name as a default -- so, sorry, I'd rather leave that up to the application to decide. Hope that's ok with you -- but keep the suggestions coming! :) -- -- Mike Mike Schilli m...@pe... |
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 |
From: Mike S. <msc...@ao...> - 2003-10-01 00:52:43
|
Roland Bauer wrote: > 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 ;-) Exactly. What do you gain by omitting the path and relying on a default? We can certainly discuss this, I'm just not (yet) seeing the benefit. Do you have a scenario? > >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) Sorry -- I did miss this question in your previous email. Actually, there's two different ways to use qw(:easy): 1) use qw(:easy) and easy_init() - one-parameter-init plus macros 2) use qw(:easy) and init() - just use the DEBUG(), ERROR(), ... macros I don't see an easy way of consolidating the two (and, we need to maintain backwards-compatibility). -- -- Mike Mike Schilli m...@pe... |
From: Roland B. <rol...@ff...> - 2003-10-02 19:47:15
|
On Tue, 30 Sep 2003 17:48:15 -0700 Mike Schilli <msc...@ao...> wrote: MS> Roland Bauer wrote: MS> MS> > If I wrote init("$ENV{HOME}/log4perl.conf") this would be portable MS> > neither. MS> > It would be just *my* modules fault instead of Log4perl's fault ;-) MS> MS> Exactly. What do you gain by omitting the path and relying on a MS> default? MS> We can certainly discuss this, I'm just not (yet) seeing the benefit. MS> Do MS> you have a scenario? I think defaults are mostly a good idea. They make things easier where you do not need full control. For most situations I personally would like to use the same configuration. So a default would be nice (for me). MS> there's two different ways to use qw(:easy): MS> MS> 1) use qw(:easy) and easy_init() - one-parameter-init plus macros MS> 2) use qw(:easy) and init() - just use the DEBUG(), ERROR(), ... macros Calling init without an argument does not seem to work, even if I use ":easy" ... or did I misunderstand your information? Regards Roland |
From: Mike S. <msc...@ao...> - 2003-10-03 00:21:44
|
Roland Bauer wrote: > Calling init without an argument does not seem to work, even if I use > ":easy" ... or did I misunderstand your information? You still have to call init(...) with the usual parameters. (:easy) just imports the macros in addition. -- -- Mike Mike Schilli m...@pe... |