IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 23, 2011, 4:27:17 PM (15 years ago)
Author:
rhenders
Message:

Introduced new logging system in order to provide proper audit trail

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/src/DetectionBatch.c

    r31025 r31030  
    4747
    4848    // open input FITS file
    49     Fits* fitsIn = existing_Fits(this->base.inputFiles[0]);
     49    Fits* fitsIn = existing_Fits(this->base.inputFiles[0], this->base.logger);
    5050    if (fitsIn->getFilePtr(fitsIn) == NULL)  return PS_EXIT_SYS_ERROR;
    5151
     
    157157    }
    158158
     159    this->base.logger->print(this->base.logger, MSG_INFO,
     160            "+-----------+---------+----------+----------------+--------------+--------------+\n");
     161    this->base.logger->print(this->base.logger, MSG_INFO,
     162            "| Extension | Rows in | Rows out |  Duplicate IDs | Invalid Flux | Bogus det ID |\n");
     163
    159164    // loop round chips
    160165    for (int x=startX; x<stopX; x++) {
     
    190195            skylist = dvoSkyListByExternID(this->base.dvoConfig, sourceId, imageId, &image);
    191196            if (skylist == NULL) {
    192                 psError(PS_ERR_IO, false,
     197                this->base.logger->print(this->base.logger, MSG_ERROR,
    193198                        "DVO: can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping this chip\n",
    194199                        sourceId, imageId, ccdNumber);
     
    205210            if (numDvoDetections > this->MAXDETECT ) {
    206211
    207                 psError(PS_ERR_IO, false, " Number of detections (%d) exceeds max limit (%ld)\n",
     212                this->base.logger->print(this->base.logger, MSG_ERROR,"Number of detections (%d) exceeds max limit (%ld)\n",
    208213                        numDvoDetections, this->MAXDETECT);
    209214                error = true;
     
    370375            }
    371376
    372             psLogMsg("ippToPsps", PS_LOG_INFO,
    373                     "+-----------+---------+----------+----------------+--------------+--------------+\n"
    374                     "| Extension | Rows in | Rows out |  Duplicate IDs | Invalid Flux | Bogus det ID |\n"
     377            this->base.logger->print(this->base.logger, MSG_INFO,
    375378                    "|  %s |  %5ld  |   %5d  |     %5d      |    %5d     |    %5d     |\n",
    376379                    extensionName, nChipDetectionsIn, nChipDetectionsOut, numOfDuplicates, numInvalidFlux, numOfInvalidIppIDet);
     
    385388    }
    386389
    387     psLogMsg("ippToPsps", PS_LOG_INFO, "Total detections for this exposure = %ld\n", totalDetectionsOut);
     390    this->base.logger->print(this->base.logger, MSG_INFO,
     391            "+-----------+---------+----------+----------------+--------------+--------------+\n");
     392
     393    this->base.logger->print(this->base.logger, MSG_INFO, "Total detections for this exposure = %ld\n", totalDetectionsOut);
    388394
    389395    // free-up memory
     
    419425    writeResults(this, minObjID, maxObjID, totalDetectionsOut);
    420426
    421     psLogMsg("ippToPsps", PS_LOG_INFO, "Data written for a total of %d chips/OTAs", nOta);
     427    this->base.logger->print(this->base.logger, MSG_INFO, "Data written for a total of %d chips/OTAs", nOta);
    422428
    423429    if (error || nOta < 1) this->base.exitCode = PS_EXIT_DATA_ERROR;
     
    481487            !haveExpName) {
    482488
    483         printf("\n* ERROR with supplied arguments:");
     489        this->base.logger->print(this->base.logger, MSG_ERROR, "Problem with supplied arguments\n");
    484490        this->print(this);
    485491        this->base.exitCode = PS_EXIT_CONFIG_ERROR;
     
    493499  Constructor. Returns a new DetectionBatch object.
    494500  */
    495 DetectionBatch* new_DetectionBatch(int *argc, char **argv) {
    496 
     501DetectionBatch* new_DetectionBatch(Logger* logger, int *argc, char **argv) {
     502
     503    logger->print(logger, MSG_DEBUG, "DetectionBatch: Constructor\n");
    497504    DetectionBatch *this = (DetectionBatch*)calloc(1, sizeof(DetectionBatch));
    498505
    499506    // call base-class constructor
    500     if (!new_Batch(&this->base)) {
    501 
    502         psError(PS_ERR_IO, false, "Unable to create Batch base-class object");
    503         return this;
    504     }
     507    new_Batch(logger, &this->base);
    505508
    506509    this->MAXDETECT = 200000;
     
    525528    psTimerStart("detectionbatch");
    526529
    527     ippToPsps_VersionPrint();
     530//    ippToPsps_VersionPrint();
    528531
    529532    int exitCode;
    530533
    531     DetectionBatch* detectionBatch = new_DetectionBatch(&argc, argv);
     534    Logger* logger = new_Logger(NULL);
     535
     536    DetectionBatch* detectionBatch = new_DetectionBatch(logger, &argc, argv);
    532537    detectionBatch->base.run(detectionBatch);
    533538    exitCode = detectionBatch->base.exitCode;
     
    537542    double secs = psTimerMark("detectionbatch");
    538543
    539     psLogMsg("detectionbatch", 3, "detectionbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
     544    logger->print(logger, MSG_INFO, "detectionbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
    540545            (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
    541546            exitCode,
     
    546551    psTimerStop();
    547552    psLibFinalize();
     553    logger->destroy(logger);
    548554
    549555    return exitCode;
Note: See TracChangeset for help on using the changeset viewer.