add function for getting early config without logging
This supports reading early config parameters from environment variables or files.
This commit is contained in:
parent
4c3fabf014
commit
d2bfbb076a
@ -59,19 +59,19 @@ sub load_logging {
|
||||
return if $LOGGING_LOADED; # already done
|
||||
return if $hooks->{'logging'}; # avoid triggering log activity
|
||||
|
||||
my @plugin_dirs = $self->conf->from_file('plugin_dirs');
|
||||
my @plugin_dirs = $self->conf->early_config('plugin_dirs');
|
||||
if (!@plugin_dirs) {
|
||||
my ($name) = ($0 =~ m!(.*?)/([^/]+)$!);
|
||||
@plugin_dirs = ("$name/plugins");
|
||||
}
|
||||
|
||||
my @loggers = $self->conf->from_file('logging');
|
||||
my @loggers = $self->conf->early_config('logging');
|
||||
for my $logger (@loggers) {
|
||||
$self->_load_plugin($logger, @plugin_dirs);
|
||||
$self->log(LOGINFO, "Loaded $logger");
|
||||
}
|
||||
|
||||
$TraceLevel = $self->conf->from_file('loglevel');
|
||||
$TraceLevel = $self->conf->early_config('loglevel');
|
||||
|
||||
unless (defined($TraceLevel) && $TraceLevel =~ /^\d+$/) {
|
||||
$TraceLevel = LOGWARN; # Default if no loglevel file found.
|
||||
|
@ -27,6 +27,17 @@ sub log {
|
||||
warn join(' ', $$, @log) . "\n";
|
||||
}
|
||||
|
||||
sub early_config {
|
||||
my ($self, $config, $file, $visited) = @_;
|
||||
|
||||
my @config;
|
||||
|
||||
@config = $self->from_environment($config);
|
||||
return wantarray ? @config : $config[0] if @config;
|
||||
|
||||
return $self->from_file($config, $file, $visited);
|
||||
}
|
||||
|
||||
sub config {
|
||||
my ($self, $qp, $c, $type) = @_;
|
||||
|
||||
@ -34,6 +45,11 @@ sub config {
|
||||
|
||||
# first run the user_config hooks
|
||||
my ($rc, @config);
|
||||
|
||||
@config = $self->from_environment($c);
|
||||
|
||||
return wantarray ? @config : $config[0] if @config;
|
||||
|
||||
if (ref $type && UNIVERSAL::can($type, 'address')) {
|
||||
($rc, @config) = $qp->run_hooks_no_respond('user_config', $type, $c);
|
||||
if (defined $rc && $rc == OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user