1 <& elements/search.html,
2 'title' => 'System Log',
3 'name_singular' => 'event',
4 'menubar' => \@menubar,
5 'html_init' => include('.head'),
7 'count_query' => $count_query,
8 'header' => [ #'#', # lognum, probably not useful
15 'fields' => [ #'lognum',
51 'download_label' => 'Download this log',
54 <STYLE type="text/css">
55 a:link {text-decoration: none}
56 a:visited {text-decoration: none}
58 background-color: #ffffff;
63 <FORM ACTION="<%$p%>search/log.html" METHOD="GET">
64 <TABLE CELLSPACING="10">
67 <& /elements/input-date-field.html, {
69 value => $cgi->param('beginning'),
73 <& /elements/input-date-field.html, {
75 value => $cgi->param('ending') || '',
82 <& /elements/select.html,
85 labels => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 },
86 curr_value => $cgi->param('min_level'),
89 <& /elements/select.html,
92 labels => { map {$_ => $FS::Log::LEVELS[$_]} 0..7 },
93 curr_value => $cgi->param('max_level'),
98 <& /elements/select.html,
100 options => \@contexts,
101 labels => { map {$_, $_} @contexts },
102 curr_value => ($cgi->param('context') || ''),
104 <BR><& /elements/checkbox.html,
105 'field' => 'context_height',
106 'postfix' => 'Only match most specific context',
108 'curr_value' => scalar($cgi->param('context_height')),
115 <& /elements/input-text.html,
119 curr_value => ($cgi->param('message') || ''),
121 <DIV STYLE="display:inline; float:right">
122 <INPUT TYPE="submit" VALUE="Refresh">
129 my $date_sub = sub { time2str('%Y-%m-%d %T', $_[0]->_date) };
131 my $level_sub = sub { $FS::Log::LEVELS[$_[0]->level] };
133 my $context_sub = sub {
135 ($log->context)[-1] . (scalar($log->context) > 1 ? '...' : '') ;
136 # XXX find a way to make this use less space (dropdown?)
141 my @context = $log->context;
142 # don't create a tooltip if there's only one context entry and the
143 # message isn't cut off
144 return '' if @context == 1 and length($log->message) <= 60;
145 my $html = '<DIV CLASS="tooltip">'.(shift @context).'</DIV>';
147 foreach (map encode_entities($_), @context, $log->message) {
148 $html .= "<DIV>$pre$_</DIV>";
149 $pre = ' '.$pre;
154 my $object_sub = sub {
156 return '' unless $log->tablename;
157 # this is a sysadmin log; anyone reading it should be able to understand
158 # 'cust_main #2319' with no trouble.
159 $log->tablename . ' #' . $log->tablenum;
162 my $message_sub = sub {
164 my $message = $log->message;
165 if ( length($message) > 60 ) { # pretty arbitrary
166 $message = substr($message, 0, 57) . '...';
171 my $object_link_sub = sub {
173 my $table = $log->tablename or return;
175 if ( grep {$_ eq $table} (qw( cust_bill cust_main cust_pkg cust_svc ))
176 or $table =~ /^svc_/ )
179 return [ $fsurl.'view/'.$table.'.cgi?'. $log->tablenum ];
181 } elsif ( grep {$_ eq $table} (qw( cust_msg cust_pay cust_pay_void
182 cust_refund cust_statement )) )
185 return [ $fsurl.'view/'.$table.'.html?', $log->tablenum ];
187 } else { # you're on your own
205 my $color_sub = sub { $colors[ $_[0]->level ]; };
207 my @contexts = ('', sort FS::log_context->contexts);
210 my $curuser = $FS::CurrentUser::CurrentUser;
212 unless $curuser->access_right([ 'View system logs', 'Configuration' ]);
215 push @menubar, qq(<A HREF="${fsurl}browse/log_email.html" STYLE="text-decoration: underline;">Configure conditions for sending email when logging</A>),
217 $cgi->param('min_level', 0) unless defined($cgi->param('min_level'));
218 $cgi->param('max_level', 7) unless defined($cgi->param('max_level'));
221 $search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ];
222 $search{'level'} = [ $cgi->param('min_level'), $cgi->param('max_level') ];
223 foreach my $param (qw(agentnum context context_height tablename tablenum custnum message)) {
224 if ( $cgi->param($param) ) {
225 $search{$param} = $cgi->param($param);
228 my $query = FS::log->search(\%search); # validates everything
229 my $count_query = delete $query->{'count_query'};