logger.pm (b274bc22) | logger.pm (0374af79) |
---|---|
1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance --- 18 unchanged lines hidden (view full) --- 27use installer::globals; 28use Time::HiRes qw(gettimeofday tv_interval); 29use English; 30use IO::Handle; 31use strict; 32 33my $StartTime = undef; 34 | 1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance --- 18 unchanged lines hidden (view full) --- 27use installer::globals; 28use Time::HiRes qw(gettimeofday tv_interval); 29use English; 30use IO::Handle; 31use strict; 32 33my $StartTime = undef; 34 |
35sub Die ($) 36{ 37 my ($message) = @_; 38 print "Stack Trace:\n"; 39 my $i = 1; 40 while ((my @call_details = (caller($i++)))) 41 { 42 printf("%s:%s in function %s\n", $call_details[1], $call_details[2], $call_details[3]); 43 } 44 45 die $message; 46} 47 48 |
|
35=head1 NAME 36 37 installer::logger 38 39 Logging for the installer modules. 40 41=cut 42 --- 110 unchanged lines hidden (view full) --- 153 If the optional $force parameter is given and it evaluates to true then the message 154 is printed even when the golbal $installer::globals::quiet is true. 155 156=cut 157sub print ($$;$) 158{ 159 my ($self, $message, $force) = @_; 160 | 49=head1 NAME 50 51 installer::logger 52 53 Logging for the installer modules. 54 55=cut 56 --- 110 unchanged lines hidden (view full) --- 167 If the optional $force parameter is given and it evaluates to true then the message 168 is printed even when the golbal $installer::globals::quiet is true. 169 170=cut 171sub print ($$;$) 172{ 173 my ($self, $message, $force) = @_; 174 |
161 die "newline at start of line" if ($message =~ /^\n.+/); | 175 Die "newline at start of line" if ($message =~ /^\n.+/); |
162 163 $force = 0 unless defined $force; 164 165 my $relative_time = tv_interval($StartTime, [gettimeofday()]); 166 foreach my $target ($self, @{$self->{'forward'}}) 167 { 168 $target->process_line( 169 $relative_time, --- 83 unchanged lines hidden (view full) --- 253 $self->{'file'} = undef; 254 } 255 256 $self->{'filename'} = $filename; 257 258 if ($filename ne "") 259 { 260 open $self->{'file'}, ">", $self->{'filename'} | 176 177 $force = 0 unless defined $force; 178 179 my $relative_time = tv_interval($StartTime, [gettimeofday()]); 180 foreach my $target ($self, @{$self->{'forward'}}) 181 { 182 $target->process_line( 183 $relative_time, --- 83 unchanged lines hidden (view full) --- 267 $self->{'file'} = undef; 268 } 269 270 $self->{'filename'} = $filename; 271 272 if ($filename ne "") 273 { 274 open $self->{'file'}, ">", $self->{'filename'} |
261 || die "can not open log file ".$self->{'filename'}." for writing"; | 275 || Die "can not open log file ".$self->{'filename'}." for writing"; |
262 $self->{'is_print_to_console'} = 0; 263 264 # Make all writes synchronous so that we don't loose any messages on an 265 # 'abrupt' end. 266 my $handle = select $self->{'file'}; 267 $| = 1; 268 select $handle; 269 } --- 111 unchanged lines hidden (view full) --- 381} 382 383#################################################### 384# Write timestamp into log file 385#################################################### 386 387sub include_timestamp_into_logfile 388{ | 276 $self->{'is_print_to_console'} = 0; 277 278 # Make all writes synchronous so that we don't loose any messages on an 279 # 'abrupt' end. 280 my $handle = select $self->{'file'}; 281 $| = 1; 282 select $handle; 283 } --- 111 unchanged lines hidden (view full) --- 395} 396 397#################################################### 398# Write timestamp into log file 399#################################################### 400 401sub include_timestamp_into_logfile 402{ |
389 die "deprected"; | 403 Die "deprected"; |
390 my ($message) = @_; 391 392 my $infoline; 393 my $timestring = get_time_string(); 394 $Lang->printf("%s\t%s", $message, $timestring); 395} 396 397#################################################### --- 188 unchanged lines hidden (view full) --- 586} 587 588############################################################### 589# Console output: messages 590############################################################### 591 592sub print_message 593{ | 404 my ($message) = @_; 405 406 my $infoline; 407 my $timestring = get_time_string(); 408 $Lang->printf("%s\t%s", $message, $timestring); 409} 410 411#################################################### --- 188 unchanged lines hidden (view full) --- 600} 601 602############################################################### 603# Console output: messages 604############################################################### 605 606sub print_message 607{ |
594 die "print_message is deprecated"; 595 | 608 Die "print_message is deprecated"; 609 |
596 my $message = shift; 597 chomp $message; 598 my $force = shift || 0; 599 print "$message\n" if ( $force || ! $installer::globals::quiet ); 600 return; 601} 602 603sub print_message_without_newline --- 36 unchanged lines hidden --- | 610 my $message = shift; 611 chomp $message; 612 my $force = shift || 0; 613 print "$message\n" if ( $force || ! $installer::globals::quiet ); 614 return; 615} 616 617sub print_message_without_newline --- 36 unchanged lines hidden --- |