summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-06-17 00:31:09 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-06-17 00:51:43 -0500
commit6acb603bb4422ca282b29e962291eb3d0d86d7bd (patch)
treec74584eba40f8ce593fc8894b0118c77bde2ef2f
parent56ff5b54ef32ac5c3c03c6762e48342033ca46d8 (diff)
RT#39627: System log daily context also includes Cron::bill and Cron::upload results [v3, search only]
-rw-r--r--FS/FS/log.pm13
-rw-r--r--httemplate/search/log.html8
2 files changed, 17 insertions, 4 deletions
diff --git a/FS/FS/log.pm b/FS/FS/log.pm
index 753a31f95..547beb7d0 100644
--- a/FS/FS/log.pm
+++ b/FS/FS/log.pm
@@ -312,9 +312,16 @@ sub search {
if ( $params->{'context'} ) {
my $quoted = dbh->quote($params->{'context'});
- push @where,
- "EXISTS(SELECT 1 FROM log_context WHERE log.lognum = log_context.lognum ".
- "AND log_context.context = $quoted)";
+ if ( $params->{'context_height'} =~ /^\d+$/ ) {
+ my $subq = 'SELECT context FROM log_context WHERE log.lognum = log_context.lognum'.
+ ' ORDER BY logcontextnum DESC LIMIT '.$params->{'context_height'};
+ push @where,
+ "EXISTS(SELECT 1 FROM ($subq) AS log_context_x WHERE log_context_x.context = $quoted)";
+ } else {
+ push @where,
+ "EXISTS(SELECT 1 FROM log_context WHERE log.lognum = log_context.lognum ".
+ "AND log_context.context = $quoted)";
+ }
}
# agent virtualization
diff --git a/httemplate/search/log.html b/httemplate/search/log.html
index 7714f4614..d4fed54c9 100644
--- a/httemplate/search/log.html
+++ b/httemplate/search/log.html
@@ -100,6 +100,12 @@ a:visited {text-decoration: none}
labels => { map {$_, $_} @contexts },
curr_value => ($cgi->param('context') || ''),
&>
+ <BR><& /elements/checkbox.html,
+ 'field' => 'context_height',
+ 'postfix' => 'Only match most specific context',
+ 'value' => 1,
+ 'curr_value' => scalar($cgi->param('context_height')),
+ &>
</TD>
</TR>
<TR>
@@ -210,7 +216,7 @@ $cgi->param('max_level', 7) unless defined($cgi->param('max_level'));
my %search = ();
$search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ];
$search{'level'} = [ $cgi->param('min_level'), $cgi->param('max_level') ];
-foreach my $param (qw(agentnum context tablename tablenum custnum message)) {
+foreach my $param (qw(agentnum context context_height tablename tablenum custnum message)) {
if ( $cgi->param($param) ) {
$search{$param} = $cgi->param($param);
}