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 => scalar($cgi->param('beginning')),
73 <& /elements/input-date-field.html, {
75 value => scalar($cgi->param('ending')) || '',
82 <& /elements/select.html,
84 options => [ &FS::Log::levelnums ],
85 labels => { &FS::Log::levelmap },
86 curr_value => scalar($cgi->param('min_level')),
89 <& /elements/select.html,
91 options => [ &FS::Log::levelnums ],
92 labels => { &FS::Log::levelmap },
93 curr_value => scalar($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
195 0 => '404040', #debug, gray
196 1 => '000000', #info, black
197 3 => '0000aa', #warning, blue
198 4 => 'aa0066', #error, purple
199 5 => 'ff0000', #critical, red
202 my $color_sub = sub { $colors{ $_[0]->level }; };
204 my @contexts = ('', FS::log_context->contexts);
207 my $curuser = $FS::CurrentUser::CurrentUser;
209 unless $curuser->access_right([ 'View system logs', 'Configuration' ]);
212 push @menubar, qq(<A HREF="${fsurl}browse/log_email.html" STYLE="text-decoration: underline;">Configure conditions for sending email when logging</A>);
214 $cgi->param('min_level', 0) unless defined($cgi->param('min_level'));
215 $cgi->param('max_level', 5) unless defined($cgi->param('max_level'));
218 $search{'date'} = [ FS::UI::Web::parse_beginning_ending($cgi) ];
219 $search{'level'} = [ $cgi->param('min_level'), $cgi->param('max_level') ];
220 foreach my $param (qw(agentnum context context_height tablename tablenum custnum message)) {
221 if ( $cgi->param($param) ) {
222 $search{$param} = $cgi->param($param);
225 my $query = FS::log->search(\%search); # validates everything
226 my $count_query = delete $query->{'count_query'};