source: branches/help/SH/arb_show_log.pl

Last change on this file was 16391, checked in by westram, 7 years ago
  • full update from child 'aci' into 'trunk'
    • allow to view console from inside ARB
    • slightly tweaked ACI trace
  • adds: log:branches/aci@16386:16390
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6sub cannot_show() {
7  print "Error: Unable to detect console logfile\n";
8  print "(Note: This only works if arb was started via the script 'arb')\n";
9  die "\n";
10}
11
12sub show_log_with_less($) {
13  my ($log) = @_;
14  print "Showing $log using less..\n";
15  my $cmd = "less +F \"$log\"";
16  # system($cmd)==0 || die "error executing '$cmd' (result=$?)"; # always fails when less is interrupted
17  system($cmd);
18}
19
20sub main() {
21  if (scalar(@ARGV)!=1) {
22    die "Usage: arb_show_log.pl logname\n ";
23  }
24
25  my $logname = $ARGV[0];
26  my $server_log = $ENV{ARB_SERVER_LOG};
27  if (not defined $server_log) {
28    print "Environment variable ARB_SERVER_LOG is not defined\n";
29    cannot_show();
30  }
31
32  if ($server_log =~ /\/([^\/]+)$/o) {
33    my $logdir = $`;
34    my $runlog = $logdir.'/'.$logname.'.log';
35    if (-f $runlog) {
36      show_log_with_less($runlog);
37    }
38    else {
39      print "Expected logfile '$runlog' not found\n";
40      cannot_show();
41    }
42  }
43  else {
44    print "Expected ARB_SERVER_LOG to contain a logfile name\n";
45    print "(contains '$server_log')\n";
46    cannot_show();
47  }
48}
49main();
Note: See TracBrowser for help on using the repository browser.