Changeset 120
- Timestamp:
- 12/13/05 08:22:27 (18 years ago)
- Location:
- trunk/soft/ObsData
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/soft/ObsData/ObsData.pm
- Property cvs2svn:cvs-rev changed from 1.38 to 1.39
r119 r120 82 82 if (!open($self->{loghandle}, ">> $self->{logfile}")) { 83 83 $self->{loghandle} = undef; 84 $self->log ing(5, "Can't open log file %s, exiting", "$self->{logfile}");84 $self->logging(5, "Can't open log file %s, exiting", "$self->{logfile}"); 85 85 return 0; 86 86 } … … 89 89 } 90 90 91 =head2 log ing($level, $message, ...)92 93 Pass a message into the log ing process.91 =head2 logging($level, $message, ...) 92 93 Pass a message into the logging process. 94 94 95 95 $level is the level of message … … 98 98 =cut 99 99 100 sub log ing {100 sub logging { 101 101 my ($self, $level, $fmt, @val) = @_; 102 102 my $msg = sprintf($fmt, @val); … … 152 152 eval { qr/$regexp/ }; # Many thanks Rafael 153 153 if ($@) { 154 $self->log ing(4, "error in regexp: '%s': %s",154 $self->logging(4, "error in regexp: '%s': %s", 155 155 $regexp, 156 156 $@, … … 354 354 my $dir = $self->getvalue($obs, ($datatype ? "datadir/$datatype" : "datadir")); 355 355 if (!$dir) { 356 $self->log ing(4,356 $self->logging(4, 357 357 "Can't find data directory for %s, type: %s", 358 358 $obs, $datatype || '(none)' … … 370 370 ); 371 371 if (!defined($or)) { 372 $self->log ing(4, "Can't parse %s, check directory exists", $dir);372 $self->logging(4, "Can't parse %s, check directory exists", $dir); 373 373 return undef; 374 374 } … … 386 386 my ($self, $obs) = @_; 387 387 my %datadir = $self->list_obsdatadir($obs); 388 $self->log ing(0, "Starting %s() for %s", (caller(0))[3], $obs);388 $self->logging(0, "Starting %s() for %s", (caller(0))[3], $obs); 389 389 390 390 foreach my $datatype (keys %datadir) { -
trunk/soft/ObsData/ObsData/Repository.pm
- Property cvs2svn:cvs-rev changed from 1.42 to 1.43
r116 r120 55 55 sub DESTROY { 56 56 my ($self) = @_; 57 $self->log ing(0, "Destroy ObsData::Repository for %s", ref($self));57 $self->logging(0, "Destroy ObsData::Repository for %s", ref($self)); 58 58 $self->save_status; 59 59 } … … 78 78 } 79 79 80 =head3 log ing($level, $msg, ...)81 82 Pass a message for log ing to ObsData Object. See L<ObsData>83 84 =cut 85 86 sub log ing {80 =head3 logging($level, $msg, ...) 81 82 Pass a message for logging to ObsData Object. See L<ObsData> 83 84 =cut 85 86 sub logging { 87 87 my $self = shift; 88 $self->{obsdata}->log ing(@_);88 $self->{obsdata}->logging(@_); 89 89 } 90 90 … … 122 122 123 123 if (!-d $self->{dir}) { 124 $self->log ing(3,124 $self->logging(3, 125 125 "directory %s does not exists", 126 126 $self->{dir}, … … 150 150 sub process { 151 151 my ($self) = @_; 152 $self->log ing(0, "%s() start for %s", (caller(0))[3], $self->{dir});152 $self->logging(0, "%s() start for %s", (caller(0))[3], $self->{dir}); 153 153 154 154 foreach my $file ($self->findfile) { … … 158 158 ); 159 159 if(!$orda->do_continue('do_archive')) { 160 $self->log ing(0,160 $self->logging(0, 161 161 "Archive %s/%s allready parsed, skipping", 162 162 $self->{dir}, … … 193 193 $or->{_cache_checks} = {}; 194 194 195 $or->log ing(0,195 $or->logging(0, 196 196 "Preparing to parse %s/%s", 197 197 $or->{dir}, … … 215 215 $self->{Oarchive} = ObsData::Archive->new("$self->{dir}/$self->{archivefile}"); 216 216 if ($self->{Oarchive}) { 217 $self->log ing(0,217 $self->logging(0, 218 218 "Archive %s/%s properly load", 219 219 $self->{dir}, $self->{archivefile} … … 221 221 return 1; 222 222 } else { 223 $self->log ing(4,223 $self->logging(4, 224 224 "Can't handle archive %s/%s: %s, skipping", 225 225 $self->{dir}, $self->{archivefile}, … … 296 296 return( 297 297 $res, 298 $self->log ing(0,298 $self->logging(0, 299 299 "%s/%s is%s new archive", 300 300 $self->{dir}, … … 311 311 defined(my $size = (stat("$self->{dir}/$self->{archivefile}"))[7])) { 312 312 my $res = $size <=> $oldsize; 313 return $res, $self->log ing(0,313 return $res, $self->logging(0, 314 314 "Size for %s/%s %s", 315 315 $self->{dir}, … … 328 328 defined(my $mtime = (stat("$self->{dir}/$self->{archivefile}"))[9])) { 329 329 my $res = $mtime <=> $oldmtime; 330 return $res, $self->log ing(0,330 return $res, $self->logging(0, 331 331 "Mtime for %s/%s %s", 332 332 $self->{dir}, … … 352 352 my $last_process = $self->gat_data_val($datafile, 'processtime'); 353 353 if ($last_process) { 354 $self->log ing(0, "%s/%s has been already processed at %s",354 $self->logging(0, "%s/%s has been already processed at %s", 355 355 $self->{archivefile}, 356 356 $datafile, … … 364 364 #sub DESTROY { 365 365 # my ($self) = @_; 366 # $self->log ing(0, "Destroy ObsData::Repository::archive for %s", ref($self));366 # $self->logging(0, "Destroy ObsData::Repository::archive for %s", ref($self)); 367 367 # $self->SUPER::DESTROY(); 368 368 #} … … 378 378 379 379 if (!$checks->{$check}) { 380 die $self->log ing(5,380 die $self->logging(5, 381 381 "check %s does not exists, exiting now", 382 382 $check … … 401 401 ($code, $text) = $self->do_check('archive_size'); 402 402 if ($code) { 403 $self->log ing(3, $text);403 $self->logging(3, $text); 404 404 } 405 405 406 406 ($code, $text) = $self->do_check('archive_mtime'); 407 407 if ($code) { 408 $self->log ing(3, $text);408 $self->logging(3, $text); 409 409 } 410 410 411 411 ($code, $text) = $self->do_check('archive_exists'); 412 412 if ($code != 0) { 413 $self->log ing(0, "%s => skiping", $text);413 $self->logging(0, "%s => skiping", $text); 414 414 return 0; 415 415 } … … 491 491 $self->{datatype} 492 492 ); 493 $self->log ing(0, "%s/%s file, datatype %s, destination %s",493 $self->logging(0, "%s/%s file, datatype %s, destination %s", 494 494 $self->{archivefile}, 495 495 $datafile, … … 536 536 537 537 if (!$destfile) { 538 $self->log ing(3,538 $self->logging(3, 539 539 "%s/%s has no destination", 540 540 $self->{archivefile}, $datafile, … … 544 544 545 545 if(!$self->do_continue('overwrite', $datafile, $destfile)) { 546 $self->log ing(3,546 $self->logging(3, 547 547 "%s extracted from %s/%s already exists, I won't overwrite it", 548 548 $destfile, … … 552 552 } 553 553 554 $self->log ing(0,554 $self->logging(0, 555 555 "Trying to extract %s from %s/%s", 556 556 $destfile, … … 561 561 562 562 if ($dirname && ! -d $dirname) { 563 $self->log ing(0, "Creating directory %s", $dirname);563 $self->logging(0, "Creating directory %s", $dirname); 564 564 if( ! File::Path::mkpath($dirname)) { 565 $self->log ing(565 $self->logging( 566 566 4, "Can't create directory %s", 567 567 $dirname … … 573 573 if ($self->{Oarchive}->extract($datafile, $destfile)) { 574 574 $self->set_data_value($datafile, 'dest', $destfile); 575 $self->log ing(575 $self->logging( 576 576 1, "Extraction of %s/%s done as %s", 577 577 $self->{archivefile}, … … 581 581 582 582 } else { 583 $self->log ing(583 $self->logging( 584 584 4, "Can't extract %s/%s to %s: %s", 585 585 $self->{archivefile}, $datafile, $destfile, … … 603 603 foreach my $data ($self->list_archive) { 604 604 if (!$self->do_continue('do_data', $data)) { 605 $self->log ing(0,605 $self->logging(0, 606 606 "%s/%s has allready processed, skipping", 607 607 $self->{archivefile}, -
trunk/soft/ObsData/t/O-02.t
- Property cvs2svn:cvs-rev changed from 1.16 to 1.17
r119 r120 14 14 ok($o->loglevel(0) eq "DEBUG", "Can get loglevel"); 15 15 ok($o->loglevel(10) eq "?????", "Can get wrong loglevel"); 16 ok($o->log ing(0, "FOO%s", "FOO") eq "FOOFOO", "loging properly return the message");16 ok($o->logging(0, "FOO%s", "FOO") eq "FOOFOO", "logging properly return the message"); 17 17 18 18 ok($o->load, "can load repository"); -
trunk/soft/ObsData/t/OR-02.t
- Property cvs2svn:cvs-rev changed from 1.7 to 1.8
r111 r120 17 17 isa_ok($or, "ObsData::Repository"); 18 18 19 ok($or->log ing(0, "FOO%s", "FOO") eq "FOOFOO", "loging return the message properly");19 ok($or->logging(0, "FOO%s", "FOO") eq "FOOFOO", "logging return the message properly"); -
trunk/soft/ObsData/t/OR-03.t
- Property cvs2svn:cvs-rev changed from 1.8 to 1.9
r115 r120 18 18 19 19 isa_ok($or, "ObsData::Repository::dir"); 20 ok($or->log ing(0, "FOO%s", "FOO") eq "FOOFOO", "loging return the message properly");20 ok($or->logging(0, "FOO%s", "FOO") eq "FOOFOO", "logging return the message properly"); 21 21 ok($or->findfile, "can find file"); 22 22 }
Note: See TracChangeset
for help on using the changeset viewer.