IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31033


Ignore:
Timestamp:
Mar 24, 2011, 11:03:32 AM (15 years ago)
Author:
rhenders
Message:

Changes to reflect those in Logger class

Location:
trunk/ippToPsps/src
Files:
7 edited

Legend:

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

    r31030 r31033  
    6363        if (this->exitCode != PS_EXIT_SUCCESS) {
    6464
    65             this->logger->print(this->logger, MSG_ERROR, "Batch: Failed, so deleting fits file\n");
     65            this->logger->print(this->logger, MSG_ERROR, "Batch", "Failed, so deleting fits file\n");
    6666            this->fitsOut->delete(this->fitsOut);
    6767        }
     
    105105    if (file == NULL) {
    106106
    107         this->logger->print(this->logger, MSG_ERROR, "Batch: Unable to open file at %s\n", this->fitsInPath);
     107        this->logger->print(this->logger, MSG_ERROR, "Batch", "Unable to open file at %s\n", this->fitsInPath);
    108108        return false;
    109109    }
     
    113113    while (fgets(line, 1000, file) != NULL) this->numOfInputFiles++;
    114114
    115     this->logger->print(this->logger, MSG_INFO, "Batch: %d input files found\n", this->numOfInputFiles);
     115    this->logger->print(this->logger, MSG_INFO, "Batch", "%d input files found\n", this->numOfInputFiles);
    116116
    117117    if (this->numOfInputFiles < 1) return false;
     
    156156    if (!this->pmconfig) {
    157157
    158         this->logger->print(this->logger, MSG_ERROR, "Batch: Unable to read configuration\n");
     158        this->logger->print(this->logger, MSG_ERROR, "Batch", "Unable to read configuration\n");
    159159        this->exitCode = PS_EXIT_CONFIG_ERROR;
    160160        return false;
  • trunk/ippToPsps/src/DetectionBatch.c

    r31030 r31033  
    157157    }
    158158
    159     this->base.logger->print(this->base.logger, MSG_INFO,
     159    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", 
    160160            "+-----------+---------+----------+----------------+--------------+--------------+\n");
    161     this->base.logger->print(this->base.logger, MSG_INFO,
     161    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", 
    162162            "| Extension | Rows in | Rows out |  Duplicate IDs | Invalid Flux | Bogus det ID |\n");
    163163
     
    195195            skylist = dvoSkyListByExternID(this->base.dvoConfig, sourceId, imageId, &image);
    196196            if (skylist == NULL) {
    197                 this->base.logger->print(this->base.logger, MSG_ERROR,
     197                this->base.logger->print(this->base.logger, MSG_ERROR, "DetectionBatch", 
    198198                        "DVO: can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping this chip\n",
    199199                        sourceId, imageId, ccdNumber);
     
    210210            if (numDvoDetections > this->MAXDETECT ) {
    211211
    212                 this->base.logger->print(this->base.logger, MSG_ERROR,"Number of detections (%d) exceeds max limit (%ld)\n",
     212                this->base.logger->print(this->base.logger, MSG_ERROR, "DetectionBatch", "Number of detections (%d) exceeds max limit (%ld)\n",
    213213                        numDvoDetections, this->MAXDETECT);
    214214                error = true;
     
    375375            }
    376376
    377             this->base.logger->print(this->base.logger, MSG_INFO,
     377            this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch",
    378378                    "|  %s |  %5ld  |   %5d  |     %5d      |    %5d     |    %5d     |\n",
    379379                    extensionName, nChipDetectionsIn, nChipDetectionsOut, numOfDuplicates, numInvalidFlux, numOfInvalidIppIDet);
     
    388388    }
    389389
    390     this->base.logger->print(this->base.logger, MSG_INFO,
     390    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", 
    391391            "+-----------+---------+----------+----------------+--------------+--------------+\n");
    392392
    393     this->base.logger->print(this->base.logger, MSG_INFO, "Total detections for this exposure = %ld\n", totalDetectionsOut);
     393    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "Total detections for this exposure = %ld\n", totalDetectionsOut);
    394394
    395395    // free-up memory
     
    425425    writeResults(this, minObjID, maxObjID, totalDetectionsOut);
    426426
    427     this->base.logger->print(this->base.logger, MSG_INFO, "Data written for a total of %d chips/OTAs", nOta);
     427    this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "Data written for a total of %d chips/OTAs\n", nOta);
    428428
    429429    if (error || nOta < 1) this->base.exitCode = PS_EXIT_DATA_ERROR;
     
    487487            !haveExpName) {
    488488
    489         this->base.logger->print(this->base.logger, MSG_ERROR, "Problem with supplied arguments\n");
     489        this->base.logger->print(this->base.logger, MSG_ERROR, "DetectionBatch", "Problem with supplied arguments\n");
    490490        this->print(this);
    491491        this->base.exitCode = PS_EXIT_CONFIG_ERROR;
     
    501501DetectionBatch* new_DetectionBatch(Logger* logger, int *argc, char **argv) {
    502502
    503     logger->print(logger, MSG_DEBUG, "DetectionBatch: Constructor\n");
     503    logger->print(logger, MSG_DEBUG, "DetectionBatch", "Constructor\n");
    504504    DetectionBatch *this = (DetectionBatch*)calloc(1, sizeof(DetectionBatch));
    505505
     
    526526int main(int argc, char **argv) {
    527527
    528     psTimerStart("detectionbatch");
    529 
    530528//    ippToPsps_VersionPrint();
    531529
    532     int exitCode;
    533 
    534530    Logger* logger = new_Logger(NULL);
     531    logger->print(logger, MSG_INFO, "main", "Creating new detection batch\n");
    535532
    536533    DetectionBatch* detectionBatch = new_DetectionBatch(logger, &argc, argv);
    537534    detectionBatch->base.run(detectionBatch);
    538     exitCode = detectionBatch->base.exitCode;
     535    int exitCode = detectionBatch->base.exitCode;
    539536
    540537    detectionBatch->destroy(detectionBatch);
    541538
    542     double secs = psTimerMark("detectionbatch");
    543 
    544     logger->print(logger, MSG_INFO, "detectionbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
    545             (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
    546             exitCode,
    547             (secs<60.0) ? secs : (secs/60.0),
    548             (secs<60.0) ? "sec(s)" : "min(s)");
    549 
    550539    // tidy up
    551     psTimerStop();
    552540    psLibFinalize();
    553541    logger->destroy(logger);
  • trunk/ippToPsps/src/Fits.c

    r31030 r31033  
    2626    if (!strncmp(typename, "TSTRING", 7)) return TSTRING;
    2727
    28 //    this->logger->print(this->logger, MSG_ERROR, "Fits: Don't understand data type '%s'", typename);
     28//    this->logger->print(this->logger, MSG_ERROR, "Fits", "Don't understand data type '%s'", typename);
    2929
    3030    return 0;
     
    3636static void destroy(Fits* this) {
    3737
    38     this->logger->print(this->logger, MSG_DEBUG, "Fits: Destructor\n");
     38    this->logger->print(this->logger, MSG_DEBUG, "Fits", "Destructor\n");
    3939
    4040    int status = 0;
    4141    if (fits_close_file(this->file, &status)) {
    4242
    43         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to close FITS file '%s'\n", this->path);
     43        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to close FITS file '%s'\n", this->path);
    4444        fits_report_error(stderr, status);
    4545    }
    4646    else
    47         this->logger->print(this->logger, MSG_INFO, "Fits: Closed FITS file '%s'\n", this->path);
     47        this->logger->print(this->logger, MSG_INFO, "Fits", "Closed FITS file '%s'\n", this->path);
    4848
    4949    free(this);
     
    6060    if (status) {
    6161
    62         this->logger->print(this->logger, MSG_ERROR, "Fits: Could not get value for header key '%s' from file at '%s'\n", name, this->path);
     62        this->logger->print(this->logger, MSG_ERROR, "Fits", "Could not get value for header key '%s' from file at '%s'\n", name, this->path);
    6363        return false;
    6464    }
     
    8686    if (status) {
    8787
    88         this->logger->print(this->logger, MSG_ERROR, "Fits: Failed to read vector column %d row %ld\n", col, row);
     88        this->logger->print(this->logger, MSG_ERROR, "Fits", "Failed to read vector column %d row %ld\n", col, row);
    8989        return false;
    9090    }
     
    102102    if (status) {
    103103
    104         this->logger->print(this->logger, MSG_ERROR, "Fits: Could not get column number for '%s'\n", name);
     104        this->logger->print(this->logger, MSG_ERROR, "Fits", "Could not get column number for '%s'\n", name);
    105105        return false;
    106106    }
     
    123123    if (status) {
    124124
    125         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read col '%s'\n", name);
     125        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to read col '%s'\n", name);
    126126        return false;
    127127    }
     
    131131    if (status) {
    132132
    133         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read type info for '%s'\n", name);
     133        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to read type info for '%s'\n", name);
    134134        return false;
    135135    }
     
    147147    if (fits_movnam_hdu(this->file, type, name, 0, &status)) {
    148148
    149         this->logger->print(this->logger, MSG_ERROR, "Fits: Can't move to table extension named '%s'\n", name);
     149        this->logger->print(this->logger, MSG_ERROR, "Fits", "Can't move to table extension named '%s'\n", name);
    150150        return false;
    151151    }
     
    178178    if (fits_get_num_rows(this->file, count, &status)) {
    179179
    180         this->logger->print(this->logger, MSG_ERROR, "Fits: Count not count rows in this table\n");
     180        this->logger->print(this->logger, MSG_ERROR, "Fits", "Count not count rows in this table\n");
    181181        return false;
    182182    }
     
    201201    if (remove(this->path) == -1) {
    202202
    203         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete '%s'\n", this->path);
    204         return false;
    205     }
    206 
    207     this->logger->print(this->logger, MSG_INFO, "Fits: Deleted FITS file at '%s'\n", this->path);
     203        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to delete '%s'\n", this->path);
     204        return false;
     205    }
     206
     207    this->logger->print(this->logger, MSG_INFO, "Fits", "Deleted FITS file at '%s'\n", this->path);
    208208
    209209    return true;
     
    235235    if (status) {
    236236
    237         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete rows using rowlist\n");
     237        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to delete rows using rowlist\n");
    238238        return false;
    239239    }
     
    290290    else {
    291291
    292         this->logger->print(this->logger, MSG_ERROR, "Fits: Don't understand datatype '%d'\n", datatype);
    293         return false;
    294     }
    295 
    296     if (status) {
    297 
    298         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read column data from column %d\n", colnum);
     292        this->logger->print(this->logger, MSG_ERROR, "Fits", "Don't understand datatype '%d'\n", datatype);
     293        return false;
     294    }
     295
     296    if (status) {
     297
     298        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to read column data from column %d\n", colnum);
    299299        return false;
    300300
     
    338338    if (status) {
    339339
    340         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to write column data for column %d\n", colnum);
     340        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to write column data for column %d\n", colnum);
    341341        return false;
    342342
     
    362362    if (status) {
    363363
    364         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create table: '%s'\n", name);
     364        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to create table: '%s'\n", name);
    365365        return false;
    366366    }
     
    415415
    416416    Fits* this = init(path, logger);
    417     this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for existing file at '%s'\n", path);
     417    this->logger->print(this->logger, MSG_DEBUG, "Fits", "Constructor for existing file at '%s'\n", path);
    418418
    419419    int status = 0;
    420420    if (fits_open_file(&this->file, path, READONLY, &status)) {
    421421
    422         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to open FITS file here %s\n", path);
     422        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to open FITS file here %s\n", path);
    423423        this->file = NULL;
    424424    }
     
    436436
    437437    Fits* this = init(path, logger);
    438     this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for new file at '%s'\n", path);
     438    this->logger->print(this->logger, MSG_DEBUG, "Fits", "Constructor for new file at '%s'\n", path);
    439439
    440440    int status = 0;
    441441    if (fits_create_file(&this->file, path, &status)) {
    442442
    443         this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create FITS file here '%s'\n", path);
     443        this->logger->print(this->logger, MSG_ERROR, "Fits", "Unable to create FITS file here '%s'\n", path);
    444444        this->file = NULL;
    445445    }
  • trunk/ippToPsps/src/FitsGenerator.c

    r31030 r31033  
    2929    }
    3030
    31     if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name);
     31    if (!column) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     32            "Could not find column '%s' in table '%s'\n", name, table->name);
    3233
    3334    return column;
     
    4950    }
    5051
    51     if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name);
     52    if (!table) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     53            "Could not find table '%s'\n", name);
    5254
    5355    return table;
     
    217219
    218220    xmlDoc* doc = xmlReadFile(path, NULL, 0);
    219     if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path);
     221    if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     222            "Unable to open XML file at %s\n", path);
    220223    return doc;
    221224}
     
    253256    if(!tableNode) {
    254257
    255         this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name);
     258        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     259                "Could not find table: %s\n", table->name);
    256260        return false;
    257261    }
     
    320324
    321325            }
    322             if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n",
     326            if (status) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     327                    "Unable to write value of %s to column %s in table %s\n",
    323328                    tempStr, table->columns[i].pspsName, table->name);
    324329        }
     
    391396    if (columnNum < 1) {
    392397
    393         this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName);
     398        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     399                "Found no columns for table '%s'\n", tableName);
    394400        ret = false;
    395401    }
    396402
    397403    if (columnNum != table->numOfColumns)
    398         this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum);
     404        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     405                "Mismatch between number of columns expected (%d) and those found (%d)\n",
     406                table->numOfColumns, columnNum);
    399407
    400408    return ret;
     
    424432    if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) {
    425433
    426         this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n");
     434        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     435                "Root node of XML is not 'tableDescriptions', as it should be\n");
    427436        return false;
    428437    }
     
    452461
    453462    if (tableNum != this->numOfTables)
    454         this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum);
     463        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     464                "Mismatch between number of tables expected (%d) and those found (%d)\n",
     465                this->numOfTables, tableNum);
    455466
    456467    closeXmlFile(doc);
     
    515526    bool ret = true;
    516527
     528    char path[1000];
     529    sprintf(path, "%s/map.xml", this->configsPath);
     530
     531    struct stat sts;
     532    if ((stat(path, &sts)) == -1) {
     533        this->logger->print(this->logger, MSG_INFO, "FitsGenerator",
     534                "No map file found at '%s'\n", path);
     535        return false;
     536    }
     537
     538    xmlDoc* doc = openXmlFile(this, path);
     539
     540    if (doc == NULL) {
     541       
     542        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator", 
     543                "Could not create XML document from '%s'\n", path);
     544        return false;
     545    }
     546
     547    this->logger->print(this->logger, MSG_INFO, "FitsGenerator",
     548            "Using map file at '%s'\n", path);
     549    xmlNode* rootElement = xmlDocGetRootElement(doc);
     550
     551    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
     552        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator", 
     553                "Root node of XML is not 'tabledata', as it should be\n");
     554        return false;
     555    }
     556
     557    xmlNode* node = NULL;
     558
     559    // loop round all available tables
     560    for (node = rootElement->children; node; node = node->next) {
     561        if (node->type == XML_ELEMENT_NODE) {
     562
     563            if (strcmp((const char*)node->name, "table")==0) {
     564
     565                if (!loadTableMappings(this, node)) ret = false;
     566            }
     567        }
     568    }
     569
     570    closeXmlFile(doc);
     571
     572    return ret;
     573}
     574
     575/**
     576  Populate the provided table with data from XML
     577  */
     578static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
     579
     580    bool ret = true;
    517581    psString path = NULL;
    518     psStringAppend(&path, "%s/map.xml", this->configsPath);
     582    psStringAppend(&path, "%s/data.xml", this->configsPath);
    519583
    520584    xmlDoc* doc = openXmlFile(this, path);
     
    529593
    530594    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    531         this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
    532         return false;
    533     }
    534 
    535     xmlNode* node = NULL;
    536 
    537     // loop round all available tables
    538     for (node = rootElement->children; node; node = node->next) {
    539         if (node->type == XML_ELEMENT_NODE) {
    540 
    541             if (strcmp((const char*)node->name, "table")==0) {
    542 
    543                 if (!loadTableMappings(this, node)) ret = false;
    544             }
    545         }
    546     }
    547 
    548     closeXmlFile(doc);
    549 
    550     return ret;
    551 }
    552 
    553 /**
    554   Populate the provided table with data from XML
    555   */
    556 static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
    557 
    558     bool ret = true;
    559     psString path = NULL;
    560     psStringAppend(&path, "%s/data.xml", this->configsPath);
    561 
    562     xmlDoc* doc = openXmlFile(this, path);
    563 
    564     if (doc == NULL) {
    565         psFree(path);
    566         return false;
    567     }
    568     psFree(path);
    569 
    570     xmlNode* rootElement = xmlDocGetRootElement(doc);
    571 
    572     if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    573         this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
     595        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     596                "Root node of XML is not 'tabledata', as it should be\n");
    574597        return false;
    575598    }
     
    679702
    680703                default:
    681                     this->logger->print(this->logger, MSG_ERROR, "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'\n", table->columns[i].ippType,
     704                    this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'\n", table->columns[i].ippType,
    682705                            table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName);
    683706                    break;
  • trunk/ippToPsps/src/InitBatch.c

    r31030 r31033  
    5959InitBatch* new_InitBatch(Logger* logger, int *argc, char **argv) {
    6060
    61     logger->print(logger, MSG_DEBUG, "InitBatch: Constructor\n");
     61    logger->print(logger, MSG_DEBUG, "InitBatch", "Constructor\n");
    6262    InitBatch *this = (InitBatch*)calloc(1, sizeof(InitBatch));
    6363
     
    8080int main(int argc, char **argv) {
    8181
    82     psTimerStart("initbatch");
    83 
    8482//    ippToPsps_VersionPrint();
    8583
    86     int exitCode;
    87 
    8884    Logger* logger = new_Logger(NULL);
     85    logger->print(logger, MSG_INFO, "main", "Creating new initialization batch\n");
    8986
    9087    InitBatch* initBatch = new_InitBatch(logger, &argc, argv);
    9188    initBatch->base.run(initBatch);
    92     exitCode = initBatch->base.exitCode;
     89    int exitCode = initBatch->base.exitCode;
    9390
    9491    initBatch->destroy(initBatch);
    9592
    96     double secs = psTimerMark("initbatch");
    97 
    98     logger->print(logger, MSG_INFO, "initbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
    99             (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
    100             exitCode,
    101             (secs<60.0) ? secs : (secs/60.0),
    102             (secs<60.0) ? "sec(s)" : "min(s)");
    10393
    10494    // tidy up
    105     psTimerStop();
    10695    psLibFinalize();
    10796    logger->destroy(logger);
  • trunk/ippToPsps/src/InitData.c

    r31030 r31033  
    6060
    6161    this->logger->print(this->logger, MSG_ERROR,
    62             "InitData: Could not find value for '%s' for '%s' with value '%s'\n",
     62            "InitData", "Could not find value for '%s' for '%s' with value '%s'\n",
    6363            attName, keyName, keyValue);
    6464
     
    8484    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    8585        this->logger->print(this->logger, MSG_ERROR,
    86                 "InitData: Root node of XML is not 'tabledata', as it should be\n");
     86                "InitData", "Root node of XML is not 'tabledata', as it should be\n");
    8787        return false;
    8888    }
     
    156156    }
    157157
    158     this->logger->print(this->logger, MSG_DEBUG, "InitData: destructor\n");
     158    this->logger->print(this->logger, MSG_DEBUG, "InitData", "Destructor\n");
    159159
    160160    free(this);
     
    166166InitData* new_InitData(const char* path, Logger* logger) {
    167167
    168 
    169 
    170168    InitData* this = (InitData*)calloc(1, sizeof(InitData));
    171169    this->logger = logger;
    172170
    173     this->logger->print(this->logger, MSG_DEBUG, "InitData: Constructor\n");
     171    this->logger->print(this->logger, MSG_DEBUG, "InitData", "Constructor\n");
    174172
    175173    sprintf(this->path, "%s/init/data.xml", path);
    176174
    177175    this->doc = xmlReadFile(this->path, NULL, 0);
    178     this->logger->print(this->logger, MSG_ERROR,
    179             "InitData: Unable to open XML file at %s\n", this->path);
     176
     177    if (this->doc == NULL)
     178        this->logger->print(this->logger, MSG_ERROR,
     179                "InitData", "Unable to open init data file at '%s'\n", this->path);
     180    else
     181        this->logger->print(this->logger, MSG_INFO,
     182                "InitData", "Using init data file at '%s'\n", this->path);
     183
    180184
    181185    // method pointers
  • trunk/ippToPsps/src/StackBatch.c

    r31030 r31033  
    5858    fitsIn->readColumnUsingName(fitsIn, TLONG, "FLAGS2", 1, 1, nDet, flags2);
    5959
    60     printf("Looping through %ld psf detections\n", nDet);
     60    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
     61            "Looping through %ld psf detection rows from '%s'\n", nDet, extensionName);
    6162    float mag;
    6263    long unmatched = 0, totalDetections = 0, numOfDuplicates = 0, numInvalidFlux = 0, numDetectionsOut = 0;
    6364
    64     this->base.logger->print(this->base.logger, MSG_INFO,
     65    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", 
    6566            "+---------------+---------+----------+------------------+---------------+--------------+\n");
    66     this->base.logger->print(this->base.logger, MSG_INFO,
     67    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", 
    6768            "|   Extension   | Rows in | Rows out | Missing from DVO | Duplicate IDs | Invalid Flux |\n");
    6869
     
    108109    }
    109110
    110     this->base.logger->print(this->base.logger, MSG_INFO,
     111    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
    111112            "|  %12s |  %5ld  |   %5ld  |      %5ld       |    %5ld      |    %5ld     |\n",
    112113            extensionName, nDet, numDetectionsOut, unmatched, numOfDuplicates, numInvalidFlux);
    113     this->base.logger->print(this->base.logger, MSG_INFO,
     114    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
    114115            "+---------------+---------+----------+------------------+---------------+--------------+\n");
    115116
     
    149150
    150151    long nDet = 0;
    151     if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, "SkyChip.xrad", &nDet)) return false;
     152    char extensionName[15];
     153    sprintf(extensionName, "SkyChip.xrad");
     154    if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, extensionName, &nDet)) return false;
    152155
    153156
     
    172175    }
    173176
    174     printf("Looping through %ld extended source detections\n", nDet);
     177    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
     178            "Looping through %ld extended source detections from extension '%s'\n", nDet, extensionName);
    175179    for (long s=0; s<nDet; s++) {
    176180
     
    271275
    272276    long nDet = 0;
    273     if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, "SkyChip.xfit", &nDet)) return false;
     277    char extensionName[40];
     278    sprintf(extensionName, "SkyChip.xfit");
     279    if (!fitsIn->moveToBinaryTableAndCountRows(fitsIn, extensionName, &nDet)) return false;
    274280
    275281    long* ippIdets = (long*)calloc(this->MAXDETECT, sizeof(long));
     
    281287    fitsIn->readColumnUsingName(fitsIn, TSTRING, "MODEL_TYPE", 1, 1, nDet, modelTypes);
    282288
    283     printf("Looping through %ld model fit rows\n", nDet);
     289    this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch",
     290            "Looping through %ld model fit rows from '%s'\n", nDet, extensionName);
    284291    for (long i = 0; i<nDet; i++) {
    285292
     
    360367    createStackDetectionTable(this, fitsIn, filterIDs, surveyIDs, skycellIDs, exposureTime);
    361368    createStackApFlxTable(this, fitsIn, filterIDs, surveyIDs);
    362     printf("dsdsdddds\n\n");
    363369    createStackModelFitTable(this, fitsIn, filterIDs, surveyIDs);
    364370    createStackToImageTable(this, fitsIn);
     
    433439StackBatch* new_StackBatch(Logger* logger, int *argc, char **argv) {
    434440
    435     logger->print(logger, MSG_DEBUG, "StackBatch: Constructor\n");
     441    logger->print(logger, MSG_DEBUG, "StackBatch", "Constructor\n");
    436442    StackBatch *this = (StackBatch*)calloc(1, sizeof(StackBatch));
    437443
     
    456462int main(int argc, char **argv) {
    457463
    458     psTimerStart("stackbatch");
    459 
    460464//    ippToPsps_VersionPrint();
    461465
     
    463467
    464468    Logger* logger = new_Logger(NULL);
     469    logger->print(logger, MSG_INFO, "main", "Creating new stack batch\n");
    465470
    466471    StackBatch* stackBatch = new_StackBatch(logger, &argc, argv);
     
    470475    stackBatch->destroy(stackBatch);
    471476
    472     double secs = psTimerMark("stackbatch");
    473 
    474     logger->print(logger, MSG_INFO, "stackbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
    475             (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
    476             exitCode,
    477             (secs<60.0) ? secs : (secs/60.0),
    478             (secs<60.0) ? "sec(s)" : "min(s)");
    479 
    480477    // tidy up
    481     psTimerStop();
     478    logger->destroy(logger);
    482479    psLibFinalize();
    483     logger->destroy(logger);
    484480
    485481    return exitCode;
Note: See TracChangeset for help on using the changeset viewer.