This file is indexed.

/usr/share/arc/LogUtils.pm is in nordugrid-arc-arex 5.0.5-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package LogUtils;

# Object-oriented usage example:
# 
#    LogUtils::level("VERBOSE");
#    $log = LogUtils->getLogger("MyProg.MyClass");
#    $log->warning("Oops!");
#    $log->error("Can't go on!");

# Procedural usage example:
#
#    start_logging('INFO');
#    warning("Oops!");
#    error("Can't go on!");

use strict;
use warnings;

use POSIX;
use FileHandle;
use File::Basename;

use Exporter;
our @ISA = ('Exporter');     # Inherit from Exporter
our @EXPORT_OK = qw(start_logging error warning info verbose debug);

our %names = (FATAL => 0, ERROR => 1, WARNING => 2, INFO => 3, VERBOSE => 4, DEBUG => 5);

our $loglevel = 2; # default level is WARNING
our $ts_enabled = 0; # by default do not print timestamps

our $default_logger = LogUtils->getLogger(basename($0));

# redirect perl warnings to ARC logging format, 
# and attempt to limit number of warnings if not verbose
my %WARNS if ($loglevel < 4);
$SIG{__WARN__} = sub {
    my $message = shift;
    chomp($message);
    if ( $loglevel < 4 ) {
		if (exists($WARNS{$message})) {
	        if ($WARNS{$message} == 1) {
				$default_logger->warning("\'PERL: $message\' repeated more than once, skipping... set loglevel to VERBOSE to see all messages.");
	            $WARNS{$message} = 2;
	            return;
	        }
	    }
	    else { 
			$default_logger->warning("PERL: $message");  
			$WARNS{$message} = 1;
			return;
		}
    }
	else { 
		$default_logger->warning("PERL: $message"); 
		return;
	}
};


# For backwards compatibility

sub start_logging($) {
    level(shift);
}

# set loglevel for all loggers
sub level {
    return $loglevel unless  @_;
    my $level = shift;
    if (defined $names{$level}) {
        $loglevel = $names{$level};
    } elsif ($level =~ m/^\d+$/ and $level < keys %names)  {
        $loglevel = $level;
    } else {
        fatal("No such loglevel '$level'");
    }
    return $loglevel;
}

# enable/disable printing of timestamps
sub timestamps {
    return $ts_enabled unless  @_;
    return $ts_enabled = shift() ? 1 : 0;
}

# constructor

sub getLogger {
    my $class = shift;
    my $self = {name => (shift || '')};
    bless $self, $class;
    return $self;
}

sub debug {
    return unless $loglevel > 4;
    unshift(@_, $default_logger) unless ref($_[0]) eq __PACKAGE__;
    my ($self, $msg) = @_;
    $self->_log('DEBUG',$msg);
}

sub verbose {
    return unless $loglevel > 3;
    unshift(@_, $default_logger) unless ref($_[0]) eq __PACKAGE__;
    my ($self, $msg) = @_;
    $self->_log('VERBOSE',$msg);
}

sub info {
    return unless $loglevel > 2;
    unshift(@_, $default_logger) unless ref($_[0]) eq __PACKAGE__;
    my ($self, $msg) = @_;
    $self->_log('INFO',$msg);
}

sub warning {
    return unless $loglevel > 1;
    unshift(@_, $default_logger) unless ref($_[0]) eq __PACKAGE__;
    my ($self, $msg) = @_;
    $self->_log('WARNING',$msg);
}

# Causes program termination
sub error {
    unshift(@_, $default_logger) unless ref($_[0]) eq __PACKAGE__;
    my ($self, $msg) = @_;
    $self->_log('ERROR',$msg);
    exit 1;
}

# Causes program termination
sub fatal {
    unshift(@_, $default_logger) unless ref($_[0]) eq __PACKAGE__;
    my ($self, $msg) = @_;
    $self->_log('FATAL',$msg);
    exit 2;
}

sub _log {
    my ($self,$severity,$msg) = @_;
    my $name = $self->{name};
    $name = $name ? "$name: " : "";
    print STDERR ($ts_enabled ? "[".timestamp()."] " : "")."$name$severity: $msg\n";
}

sub timestamp {
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
    return POSIX::strftime("%Y-%m-%d %H:%M:%S", $sec,$min,$hour,$mday,
                           $mon,$year,$wday,$yday,$isdst);
}

sub test {
    LogUtils::level('INFO');
    LogUtils::timestamps(1);
    my $log = LogUtils->getLogger();
    $log->warning("Hi");
    $log = LogUtils->getLogger("main");
    $log->warning("Hi");
    $log = LogUtils->getLogger("main.sub");
    $log->warning("Hi");
    $log = LogUtils->getLogger("main.sub.one");
    $log->warning("Hi");
    LogUtils->getLogger("main.sub.too")->info("Boo");
    LogUtils->getLogger("main.sub.too")->debug("Hoo");
}

sub test2 {
    start_logging('VERBOSE');
    debug('geee');
    info('beee');
    warning('meee');
    error('mooo');
}

#test();
#test2();

1;