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') || ''),
109 <& /elements/input-text.html,
113 curr_value => ($cgi->param('message') || ''),
115 <DIV STYLE="display:inline; float:right">
116 <INPUT TYPE="submit" VALUE="Refresh">
123 my $date_sub = sub { time2str('%Y-%m-%d %T', $_[0]->_date) };
125 my $level_sub = sub { $FS::Log::LEVELS[$_[0]->level] };
127 my $context_sub = sub {
129 ($log->context)[-1] . (scalar($log->context) > 1 ? '...' : '') ;
130 # XXX find a way to make this use less space (dropdown?)
135 my @context = $log->context;
136 # don't create a tooltip if there's only one context entry and the
137 # message isn't cut off
138 return '' if @context == 1 and length($log->message) <= 60;
139 my $html = '<DIV CLASS="tooltip">'.(shift @context).'</DIV>';
141 foreach (map encode_entities($_), @context, $log->message) {
142 $html .= "<DIV>$pre$_</DIV>";
143 $pre = ' '.$pre;
148 my $object_sub = sub {
150 return '' unless $log->tablename;
151 # this is a sysadmin log; anyone reading it should be able to understand
152 # 'cust_main #2319' with no trouble.
153 $log->tablename . ' #' . $log->tablenum;
156 my $message_sub = sub {
158 my $message = $log->message;
159 if ( length($message) > 60 ) { # pretty arbitrary
160 $message = substr($message, 0, 57) . '...';
165 my $object_link_sub = sub {
167 my $table = $log->tablename or return;
169 if ( grep {$_ eq $table} (qw( cust_bill cust_main cust_pkg cust_svc ))
170 or $table =~ /^svc_/ )
173 return [ $fsurl.'view/'.$table.'.cgi?'. $log->tablenum ];
175 } elsif ( grep {$_ eq $table} (qw( cust_msg cust_pay cust_pay_void
176 cust_refund cust_statement )) )
179 return [ $fsurl.'view/'.$table.'.html?', $log->tablenum ];
181 } else { # you're on your own
199 my $color_sub = sub { $colors[ $_[0]->level ]; };
201 my @contexts = ('', sort FS::log_context->contexts);
204 my $curuser = $FS::CurrentUser::CurrentUser;
206 unless $curuser->access_right([ 'View system logs', 'Configuration' ]);
209 push @menubar, qq(<A HREF="${fsurl}browse/log_email.html" STYLE="text-decoration: underline;">Configure conditions for sending email when logging</A>),
211 $cgi->param('min_level', 0) unless defined($cgi->param('min_level'));
212 $cgi->param('max_level', 7) unless defined($cgi->param('max_level'));
215 $search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ];
216 $search{'level'} = [ $cgi->param('min_level'), $cgi->param('max_level') ];
217 foreach my $param (qw(agentnum context tablename tablenum custnum message)) {
218 if ( $cgi->param($param) ) {
219 $search{$param} = $cgi->param($param);
222 my $query = FS::log->search(\%search); # validates everything
223 my $count_query = delete $query->{'count_query'};