make sure $transaction->notes is blessed before
calling it as such. It doesn't resolve #199 but it does help there. I'm not sure initializing Qpsmtpd::transaction as {} is a brilliant idea, but I haven't a better solution for that yet.
This commit is contained in:
parent
0d79c1ef8e
commit
d9ac50f383
@ -32,8 +32,9 @@ sub register_hook {
|
|||||||
|
|
||||||
die $plugin->plugin_name . ": Invalid hook: $hook" unless $hooks{$hook};
|
die $plugin->plugin_name . ": Invalid hook: $hook" unless $hooks{$hook};
|
||||||
|
|
||||||
$plugin->{_qp}->log(LOGDEBUG, $plugin->plugin_name, "hooking", $hook)
|
if ($hook !~ /logging/) { # can't log during load_logging()
|
||||||
unless $hook =~ /logging/; # can't log during load_logging()
|
$plugin->{_qp}->log(LOGDEBUG, $plugin->plugin_name, 'hooking', $hook);
|
||||||
|
}
|
||||||
|
|
||||||
# I can't quite decide if it's better to parse this code ref or if
|
# I can't quite decide if it's better to parse this code ref or if
|
||||||
# we should pass the plugin object and method name ... hmn.
|
# we should pass the plugin object and method name ... hmn.
|
||||||
|
@ -230,7 +230,9 @@ sub maybe_reopen {
|
|||||||
unless ($self->open_log($new_output, $transaction)) {
|
unless ($self->open_log($new_output, $transaction)) {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
if (UNIVERSAL::can($transaction,'isa')) {
|
||||||
$transaction->notes('file-reopened-this-session', 1);
|
$transaction->notes('file-reopened-this-session', 1);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -262,10 +264,12 @@ sub hook_disconnect {
|
|||||||
sub hook_logging {
|
sub hook_logging {
|
||||||
my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
|
my ($self, $transaction, $trace, $hook, $plugin, @log) = @_;
|
||||||
|
|
||||||
return DECLINED
|
if (!defined $self->{_loglevel}) { return DECLINED; }
|
||||||
if !defined $self->{_loglevel}
|
if ($trace > $self->{_loglevel}) { return DECLINED; }
|
||||||
or $trace > $self->{_loglevel};
|
|
||||||
return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
|
if (defined $plugin && $plugin eq $self->plugin_name) {
|
||||||
|
return DECLINED;
|
||||||
|
}
|
||||||
|
|
||||||
# Possibly reopen the log iff:
|
# Possibly reopen the log iff:
|
||||||
# - It's not already open
|
# - It's not already open
|
||||||
@ -280,8 +284,10 @@ sub hook_logging {
|
|||||||
unless (defined $self->maybe_reopen($transaction)) {
|
unless (defined $self->maybe_reopen($transaction)) {
|
||||||
return DECLINED;
|
return DECLINED;
|
||||||
}
|
}
|
||||||
|
if (UNIVERSAL::can($transaction,'isa')) {
|
||||||
$transaction->notes('file-logged-this-session', 1) if $transaction;
|
$transaction->notes('file-logged-this-session', 1) if $transaction;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $f = $self->{_f};
|
my $f = $self->{_f};
|
||||||
print $f strftime($self->{_tsformat}, localtime), ' ',
|
print $f strftime($self->{_tsformat}, localtime), ' ',
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
#
|
#
|
||||||
# Example configuration file for plugins
|
# Test configuration file for plugins
|
||||||
#
|
#
|
||||||
|
|
||||||
# enable this to get configuration via http; see perldoc
|
# enable this to get configuration via http; see perldoc
|
||||||
# plugins/http_config for details.
|
# plugins/http_config for details.
|
||||||
# http_config http://localhost/~smtpd/config/ http://www.example.com/smtp.pl?config=
|
# http_config http://localhost/~smtpd/config/ http://www.example.com/smtp.pl?config=
|
||||||
|
|
||||||
|
logging/syslog
|
||||||
|
logging/warn
|
||||||
|
logging/file t/tmp/test-warn.log
|
||||||
|
|
||||||
|
content_log
|
||||||
|
|
||||||
# hosts_allow does not work with the tcpserver deployment model!
|
# hosts_allow does not work with the tcpserver deployment model!
|
||||||
# perldoc plugins/hosts_allow for an alternative.
|
# perldoc plugins/hosts_allow for an alternative.
|
||||||
#
|
#
|
||||||
@ -13,7 +19,6 @@
|
|||||||
# my $MAXCONNIP = 5; # max simultaneous connections from one IP
|
# my $MAXCONNIP = 5; # max simultaneous connections from one IP
|
||||||
# settings... without this it will NOT refuse more than $MAXCONNIP connections
|
# settings... without this it will NOT refuse more than $MAXCONNIP connections
|
||||||
# from one IP!
|
# from one IP!
|
||||||
content_log
|
|
||||||
hosts_allow
|
hosts_allow
|
||||||
|
|
||||||
# information plugins
|
# information plugins
|
||||||
|
@ -141,7 +141,8 @@ sub __log {
|
|||||||
warn @_;
|
warn @_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ok($qp->log(LOGWARN, "test log message"), 'log');
|
$qp->log(LOGWARN, "test log message");
|
||||||
|
ok(-f 't/tmp/test-warn.log', 'log');
|
||||||
is($warned, "$$ test log message\n", 'LOGWARN emitted correct warning');
|
is($warned, "$$ test log message\n", 'LOGWARN emitted correct warning');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user