[freeside-commits] branch FREESIDE_3_BRANCH updated. 03581a2d9d8cc76d3fb88cbc78da3128b137157a
Mitch Jackson
mitch at freeside.biz
Sat Oct 27 20:20:49 PDT 2018
The branch, FREESIDE_3_BRANCH has been updated
via 03581a2d9d8cc76d3fb88cbc78da3128b137157a (commit)
from 793113e437c711b726f3b2fefb3091ff93ddd4d7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 03581a2d9d8cc76d3fb88cbc78da3128b137157a
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Fri Jun 17 00:31:09 2016 -0500
RT#39627: System log daily context also includes Cron::bill and Cron::upload results
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index ecd071e49..2168c4c39 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4665,6 +4665,7 @@ sub tables_hashref {
'min_level', 'int', 'NULL', '', '', '',
'msgnum', 'int', '', '', '', '',
'to_addr', 'varchar', 'NULL', 255, '', '',
+ 'context_height', 'int', 'NULL', '', '', '',
],
'primary_key' => 'logemailnum',
'unique' => [],
diff --git a/FS/FS/log.pm b/FS/FS/log.pm
index 67a74d196..64d036e4d 100644
--- a/FS/FS/log.pm
+++ b/FS/FS/log.pm
@@ -87,14 +87,15 @@ sub insert {
return $error if $error;
my $contexts = {};
- foreach ( @_ ) {
+ my $context_height = @_;
+ foreach ( @_ ) { # ordered from least to most specific
my $context = FS::log_context->new({
'lognum' => $self->lognum,
'context' => $_
});
$error = $context->insert;
return $error if $error;
- $contexts->{$_} = 1;
+ $contexts->{$_} = $context_height--;
}
foreach my $log_email (
@@ -108,8 +109,9 @@ sub insert {
}
)
) {
- # shouldn't be a lot of these, so not packing this into the qsearch
+ # shouldn't be a lot of log_email records, so not packing these checks into the qsearch
next if $log_email->context && !$contexts->{$log_email->context};
+ next if $log_email->context_height && ($contexts->{$log_email->context} > $log_email->context_height);
my $msg_template = qsearchs('msg_template',{ 'msgnum' => $log_email->msgnum });
unless ($msg_template) {
warn "Could not send email when logging, could not load message template for logemailnum " . $log_email->logemailnum;
diff --git a/FS/FS/log_email.pm b/FS/FS/log_email.pm
index 9c53c230a..a055cb4c6 100644
--- a/FS/FS/log_email.pm
+++ b/FS/FS/log_email.pm
@@ -42,6 +42,9 @@ The following fields are currently supported:
=item to_addr - who the email will be sent to (in addition to any bcc on the template)
+=item context_height - number of context stack levels to match against
+(0 or null matches against full stack, 1 only matches lowest level context, 2 matches lowest two levels, etc.)
+
=back
=head1 METHODS
@@ -88,6 +91,7 @@ sub check {
|| $self->ut_number('min_level')
|| $self->ut_foreign_key('msgnum', 'msg_template', 'msgnum')
|| $self->ut_textn('to_addr')
+ || $self->ut_numbern('context_height')
;
return $error if $error;
diff --git a/httemplate/edit/log_email.html b/httemplate/edit/log_email.html
index 19b415d4d..b79aba986 100644
--- a/httemplate/edit/log_email.html
+++ b/httemplate/edit/log_email.html
@@ -8,6 +8,12 @@
'labels' => { '' => '(all)', map { $_ => $_ } @contexts },
'curr_value' => scalar($cgi->param('context')),
},
+ { 'field' => 'context_height',
+ 'type' => 'checkbox',
+ 'postfix' => 'Only match most specific context',
+ 'value' => 1,
+ 'curr_value' => scalar($cgi->param('context_height')),
+ },
{ 'field' => 'min_level',
'type' => 'select',
'options' => [ &FS::Log::levelnums ],
@@ -24,6 +30,7 @@
],
'labels' => {
'context' => 'Context',
+ 'context_height' => '',
'min_level' => 'Min. Level',
'to_addr' => 'To',
'msgnum' => 'Message',
@@ -44,6 +51,10 @@ die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right([ 'View system logs', 'Configuration' ]);
my $msgnum = $cgi->param('msgnum');
+
+# XXX This attempt to set a default message isn't working, not sure why
+# $msgnum gets set correctly, but isn't selected in the popup window...fix later
+
unless ($msgnum) {
my ($msg_template) = qsearch('msg_template',{ msgname => 'System log' });
# doesn't seem worth having a config just for the default selected template
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Schema.pm | 1 +
FS/FS/log.pm | 8 +++++---
FS/FS/log_email.pm | 4 ++++
httemplate/edit/log_email.html | 11 +++++++++++
4 files changed, 21 insertions(+), 3 deletions(-)
More information about the freeside-commits
mailing list