1 <& elements/search.html,
2 'title' => 'System Log',
3 'name_singular' => 'event',
4 'html_init' => include('.head'),
6 'count_query' => $count_query,
7 'header' => [ #'#', # lognum, probably not useful
14 'fields' => [ #'lognum',
50 'download_label' => 'Download this log',
53 <STYLE type="text/css">
54 a:link {text-decoration: none}
55 a:visited {text-decoration: none}
57 background-color: #ffffff;
62 <FORM ACTION="<%$p%>search/log.html" METHOD="GET">
63 <TABLE CELLSPACING="10">
66 <& /elements/input-date-field.html, {
68 value => scalar($cgi->param('beginning')),
72 <& /elements/input-date-field.html, {
74 value => scalar($cgi->param('ending')) || '',
81 <& /elements/select.html,
84 labels => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 },
85 curr_value => scalar($cgi->param('min_level')),
88 <& /elements/select.html,
91 labels => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 },
92 curr_value => scalar($cgi->param('max_level')),
97 <& /elements/select.html,
99 options => \@contexts,
100 labels => { map {$_, $_} @contexts },
101 curr_value => ($cgi->param('context') || ''),
103 <BR><& /elements/checkbox.html,
104 'field' => 'context_height',
105 'postfix' => 'Only match most specific context',
107 'curr_value' => scalar($cgi->param('context_height')),
114 <& /elements/input-text.html,
118 curr_value => ($cgi->param('message') || ''),
120 <DIV STYLE="display:inline; float:right">
121 <INPUT TYPE="submit" VALUE="Refresh">
128 my $date_sub = sub { time2str('%Y-%m-%d %T', $_[0]->_date) };
130 my $level_sub = sub { $FS::Log::LEVELS[$_[0]->level] };
132 my $context_sub = sub {
134 ($log->context)[-1] . (scalar($log->context) > 1 ? '...' : '') ;
135 # XXX find a way to make this use less space (dropdown?)
140 my @context = $log->context;
141 # don't create a tooltip if there's only one context entry and the
142 # message isn't cut off
143 return '' if @context == 1 and length($log->message) <= 60;
144 my $html = '<DIV CLASS="tooltip">'.(shift @context).'</DIV>';
146 foreach (map encode_entities($_), @context, $log->message) {
147 $html .= "<DIV>$pre$_</DIV>";
148 $pre = ' '.$pre;
153 my $object_sub = sub {
155 return '' unless $log->tablename;
156 # this is a sysadmin log; anyone reading it should be able to understand
157 # 'cust_main #2319' with no trouble.
158 $log->tablename . ' #' . $log->tablenum;
161 my $message_sub = sub {
163 my $message = $log->message;
164 if ( length($message) > 60 ) { # pretty arbitrary
165 $message = substr($message, 0, 57) . '...';
170 my $object_link_sub = sub {
172 my $table = $log->tablename or return;
174 if ( grep {$_ eq $table} (qw( cust_bill cust_main cust_pkg cust_svc ))
175 or $table =~ /^svc_/ )
178 return [ $fsurl.'view/'.$table.'.cgi?'. $log->tablenum ];
180 } elsif ( grep {$_ eq $table} (qw( cust_msg cust_pay cust_pay_void
181 cust_refund cust_statement )) )
184 return [ $fsurl.'view/'.$table.'.html?', $log->tablenum ];
186 } else { # you're on your own
204 my $color_sub = sub { $colors[ $_[0]->level ]; };
206 my @contexts = ('', sort FS::log_context->contexts);
209 my $curuser = $FS::CurrentUser::CurrentUser;
211 unless $curuser->access_right([ 'View system logs', 'Configuration' ]);
213 $cgi->param('min_level', 0) unless defined($cgi->param('min_level'));
214 $cgi->param('max_level', 7) unless defined($cgi->param('max_level'));
217 $search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ];
218 $search{'level'} = [ $cgi->param('min_level'), $cgi->param('max_level') ];
219 foreach my $param (qw(agentnum context context_height tablename tablenum custnum message)) {
220 if ( $cgi->param($param) ) {
221 $search{$param} = $cgi->param($param);
224 my $query = FS::log->search(\%search); # validates everything
225 my $count_query = delete $query->{'count_query'};