Handle hostnames with upper-case letters
[webmin.git] / proc / log_parser.pl
1 # log_parser.pl
2 # Functions for parsing this module's logs
3
4 do 'proc-lib.pl';
5
6 # parse_webmin_log(user, script, action, type, object, &params)
7 # Converts logged information from this module into human-readable form
8 sub parse_webmin_log
9 {
10 local ($user, $script, $action, $type, $object, $p, $long) = @_;
11 if ($action eq 'run') {
12         return &text('log_run', "<tt>".&html_escape($p->{'cmd'})."</tt>");
13         }
14 elsif ($action eq 'kill') {
15         local ($desc, $i);
16         @pids = $p->{'pid'} ? ( $p->{'pid'} ) : split(/\s+/, $p->{'pidlist'});
17         if ($long) {
18                 for($i=0; $i<@pids; $i++) {
19                         $desc .= "<i>".$p->{"args$i"}.
20                                  "</i>&nbsp;&nbsp;(PID $pids[$i])<br>";
21                         }
22                 return &text(@pids == 1 ? 'log_kill_l' : 'log_kills_l',
23                              "<tt>$p->{'signal'}</tt>", $desc);
24                 }
25         else {
26                 if (@pids == 1) {
27                         return &text('log_kill', "<tt>$p->{'signal'}</tt>",
28                                      $pids[0]);
29                         }
30                 else {
31                         return &text('log_kills', "<tt>$p->{'signal'}</tt>",
32                                      scalar(@pids));
33                         }
34                 }
35         }
36 elsif ($action eq 'renice') {
37         return &text('log_renice', $p->{'nice'}, $p->{'pid'});
38         }
39 else {
40         return undef;
41         }
42 }
43