IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31030


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

Location:
trunk/ippToPsps/src
Files:
2 added
15 edited

Legend:

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

    r31025 r31030  
    6363        if (this->exitCode != PS_EXIT_SUCCESS) {
    6464
    65             psError(PS_ERR_UNKNOWN, false, "Failed, so deleting fits file");
     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         psError(PS_ERR_UNKNOWN, false, "Unable to open file at %s", 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     printf ("Number of input files %d\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         psError(PS_ERR_UNKNOWN, false, "Unable to read configuration.");
     158        this->logger->print(this->logger, MSG_ERROR, "Batch: Unable to read configuration\n");
    159159        this->exitCode = PS_EXIT_CONFIG_ERROR;
    160160        return false;
     
    220220
    221221    // create an InitData object and get survey ID
    222     this->initData = new_InitData(configsBaseDir);
     222    this->initData = new_InitData(configsBaseDir, this->logger);
    223223    if (strlen(this->surveyType) > 0 &&
    224224            !this->initData->getSurveyId(this->initData, this->surveyType, &this->surveyID)) {
     
    230230    // create a FitsGenerator object
    231231    strcat(configsBaseDir, configsDir);
    232     this->fitsGenerator = new_FitsGenerator(configsBaseDir);
     232    this->fitsGenerator = new_FitsGenerator(this->logger, configsBaseDir);
    233233
    234234    // create full FITS out path
     
    236236
    237237    // create an output FITS file
    238     this->fitsOut = new_Fits(fitsOutPath);
     238    this->fitsOut = new_Fits(fitsOutPath, this->logger);
    239239    if (this->fitsOut->getFilePtr(this->fitsOut) == NULL) return false;
    240240
     
    306306  Constructor. Takes a Batch object and initialises it.
    307307  */
    308 bool new_Batch(Batch *this) {
    309 
     308bool new_Batch(Logger* logger, Batch *this) {
     309
     310    this->logger = logger;
    310311    this->surveyID = -1;
    311312    this->resultsXmlDoc = NULL;
  • trunk/ippToPsps/src/Batch.h

    r31025 r31030  
    1 /** @file ippToPsps.h
     1/** @file Batch.h
    22 *
    33 *  @brief Batch
     
    66 *
    77 *  @author IfA
    8  *  Copyright 2009 Institute for Astronomy, University of Hawaii
     8 *  Copyright 2011 Institute for Astronomy, University of Hawaii
    99 */
    1010
     
    2121#include "Fits.h"
    2222#include "InitData.h"
     23#include "Logger.h"
    2324
    2425/**
     
    4950    int exitCode;                  // ps exit code
    5051    bool testMode;                 // test mode boolean
     52    Logger* logger;                // Logger object
    5153
    5254    // methods
     
    6668
    6769// public functions
    68 bool new_Batch(Batch *this);
     70bool new_Batch(Logger* logger, Batch *this);
    6971
    7072void ippToPsps_VersionPrint(void);
  • 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;
  • trunk/ippToPsps/src/DetectionBatch.h

    r30190 r31030  
    3131} DetectionBatch;
    3232
    33 DetectionBatch *new_DetectionBatch(int *argc, char **argv);
     33DetectionBatch *new_DetectionBatch(Logger* logger, int *argc, char **argv);
    3434
    3535# endif // IPPTOPSPS_DETECTIONBATCH_H
  • trunk/ippToPsps/src/Fits.c

    r31016 r31030  
    2626    if (!strncmp(typename, "TSTRING", 7)) return TSTRING;
    2727
    28     psError(PS_ERR_IO, false, "* 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");
     39
    3840    int status = 0;
    3941    if (fits_close_file(this->file, &status)) {
    4042
    41         psError(PS_ERR_IO, false, "* Fits: Unable to close FITS file");
     43        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to close FITS file '%s'\n", this->path);
    4244        fits_report_error(stderr, status);
    4345    }
    4446    else
    45         psLogMsg("ippToPsps", PS_LOG_INFO, "* Fits: Closed '%s'", this->path);
     47        this->logger->print(this->logger, MSG_INFO, "Fits: Closed FITS file '%s'\n", this->path);
     48
     49    free(this);
    4650}
    4751
     
    5660    if (status) {
    5761
    58         psError(PS_ERR_IO, false, "* Fits: Could not get value for header key '%s'\n", name);
     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);
    5963        return false;
    6064    }
     
    8286    if (status) {
    8387
    84         psError(PS_ERR_IO, false, "* Fits: Failed to read vector column %d row %ld", col, row);
     88        this->logger->print(this->logger, MSG_ERROR, "Fits: Failed to read vector column %d row %ld\n", col, row);
    8589        return false;
    8690    }
     
    98102    if (status) {
    99103
    100         psError(PS_ERR_IO, false, "* 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);
    101105        return false;
    102106    }
     
    119123    if (status) {
    120124
    121         psError(PS_ERR_IO, false, "* Fits: Unable to read col '%s'", name);
     125        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read col '%s'\n", name);
    122126        return false;
    123127    }
     
    127131    if (status) {
    128132
    129         psError(PS_ERR_IO, false, "* Fits: Unable to read type info for '%s'", name);
     133        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read type info for '%s'\n", name);
    130134        return false;
    131135    }
     
    143147    if (fits_movnam_hdu(this->file, type, name, 0, &status)) {
    144148
    145         psError(PS_ERR_IO, false, "* 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);
     150        return false;
    146151    }
    147152
     
    173178    if (fits_get_num_rows(this->file, count, &status)) {
    174179
    175         psError(PS_ERR_IO, false, "* 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");
    176181        return false;
    177182    }
     
    196201    if (remove(this->path) == -1) {
    197202
    198         psError(PS_ERR_UNKNOWN, false, "* Fits: Unable to delete '%s'", this->path);
    199         return false;
    200     }
     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);
    201208
    202209    return true;
     
    228235    if (status) {
    229236
    230         psError(PS_ERR_IO, false, "* Fits: Unable to delet rows using rowlist \n");
     237        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete rows using rowlist\n");
    231238        return false;
    232239    }
     
    283290    else {
    284291
    285         psError(PS_ERR_IO, false, "* Fits: Don't support datatype '%d' yet\n", datatype);
    286         return false;
    287     }
    288 
    289     if (status) {
    290 
    291         psError(PS_ERR_IO, false, "* 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);
    292299        return false;
    293300
     
    331338    if (status) {
    332339
    333         psError(PS_ERR_IO, false, "* 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);
    334341        return false;
    335342
     
    355362    if (status) {
    356363
    357         psError(PS_ERR_IO,"* Fits: Unable to create table: '%s'", name);
     364        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create table: '%s'\n", name);
    358365        return false;
    359366    }
     
    366373  Initilization common to all constructors
    367374  */
    368 static void init(Fits* this) {
     375static Fits* init(const char* path, Logger* logger) {
     376
     377    Fits* this = (Fits*)calloc(1, sizeof(Fits));
     378
     379    // fields
     380    strcpy(this->path, path);
     381    this->logger = logger;
    369382
    370383    // method pointers
     
    390403    assert(this);
    391404
     405    return this;
    392406}
    393407
     
    398412
    399413*/
    400 Fits* existing_Fits(char* path) {
    401 
    402     Fits* this = (Fits*)calloc(1, sizeof(Fits));
    403 
    404     int status = 0;
    405     strcpy(this->path, path);
    406 
    407     if (fits_open_file(&this->file, this->path, READONLY, &status)) {
    408 
    409         psError(PS_ERR_IO, false, "* Fits: Unable to open FITS file here %s\n", path);
     414Fits* existing_Fits(const char* path, Logger* logger) {
     415
     416    Fits* this = init(path, logger);
     417    this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for existing file at '%s'\n", path);
     418
     419    int status = 0;
     420    if (fits_open_file(&this->file, path, READONLY, &status)) {
     421
     422        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to open FITS file here %s\n", path);
    410423        this->file = NULL;
    411424    }
    412425
    413     init(this);
    414426
    415427    return this;
     
    421433  Returns a new Fits object representing a new FITS file.
    422434  */
    423 Fits* new_Fits(char* path) {
    424 
    425     Fits* this = (Fits*)calloc(1, sizeof(Fits));
    426 
    427     int status = 0;
    428     strcpy(this->path, path);
    429 
    430     if (fits_create_file(&this->file, this->path, &status)) {
    431 
    432         psError(PS_ERR_IO, false, "* Fits: Unable to create file here '%s'", path);
     435Fits* new_Fits(const char* path, Logger* logger) {
     436
     437    Fits* this = init(path, logger);
     438    this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for new file at '%s'\n", path);
     439
     440    int status = 0;
     441    if (fits_create_file(&this->file, path, &status)) {
     442
     443        this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create FITS file here '%s'\n", path);
    433444        this->file = NULL;
    434445    }
    435446
    436     init(this);
    437 
    438447    return this;
    439448}
  • trunk/ippToPsps/src/Fits.h

    r31025 r31030  
    1414#include <psmodules.h>
    1515
     16#include "Logger.h"
     17
    1618/**
    1719
     
    2426    fitsfile* file;             // cfitsio file pointer
    2527    char path[1000];            // FITS path
     28    Logger* logger;             // logger object
    2629
    2730    // accessor methods
     
    5356
    5457// constructors
    55 Fits* existing_Fits(char* path);
    56 Fits* new_Fits(char* path);
     58Fits* existing_Fits(const char* path, Logger* logger);
     59Fits* new_Fits(const char* path, Logger* logger);
    5760
    5861// non-class methods
  • trunk/ippToPsps/src/FitsGenerator.c

    r31025 r31030  
    1717  Finds a column within this table
    1818  */
    19 static Column* findColumn(Table* table, const char* name) {
     19static Column* findColumn(FitsGenerator* this, Table* table, const char* name) {
    2020
    2121    Column* column = NULL;
     
    2929    }
    3030
    31     if (!column) psError(PS_ERR_IO, false, "Could not find column '%s' in table '%s'", name, table->name);
     31    if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name);
    3232
    3333    return column;
     
    4949    }
    5050
    51     if (!table) psError(PS_ERR_IO, false, "Could not find table '%s'", name);
     51    if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name);
    5252
    5353    return table;
     
    214214   opens an XML file and returns the document
    215215   */
    216 static xmlDoc* openXmlFile(const char* path) {
     216static xmlDoc* openXmlFile(FitsGenerator* this, const char* path) {
    217217
    218218    xmlDoc* doc = xmlReadFile(path, NULL, 0);
    219     if (doc == NULL) psError(PS_ERR_IO, false, "Unable to open XML file at %s", path);
     219    if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path);
    220220    return doc;
    221221}
     
    235235  Populates the provided table with data from XML
    236236  */
    237 static bool populateTable(Table* table, xmlNode* rootElement, Fits *fitsOut) {
     237static bool populateTable(FitsGenerator* this, Table* table, xmlNode* rootElement, Fits *fitsOut) {
    238238
    239239    char tempStr[100];
     
    253253    if(!tableNode) {
    254254
    255         psError(PS_ERR_IO,"Could not find table: %s", table->name);
     255        this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name);
    256256        return false;
    257257    }
     
    320320
    321321            }
    322             if (status) psError(PS_ERR_IO, false, "Unable to write value of %s to column %s in table %s",
     322            if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n",
    323323                    tempStr, table->columns[i].pspsName, table->name);
    324324        }
     
    339339  Loads a table description from XML
    340340  */
    341 static bool loadTableDescription(Table* table, xmlNode* tableNode) {
     341static bool loadTableDescription(FitsGenerator* this, Table* table, xmlNode* tableNode) {
    342342
    343343    bool ret = true;
     
    391391    if (columnNum < 1) {
    392392
    393         psError(PS_ERR_IO, false, "Found no columns for table '%s'", tableName);
     393        this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName);
    394394        ret = false;
    395395    }
    396396
    397397    if (columnNum != table->numOfColumns)
    398         psError(PS_ERR_IO, false, "Mismatch between number of columns expected (%d) and those found (%d)", table->numOfColumns, columnNum);
     398        this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum);
    399399
    400400    return ret;
     
    411411    psStringAppend(&path, "%s/tables.xml", this->configsPath);
    412412
    413     xmlDoc* doc = openXmlFile(path);
     413    xmlDoc* doc = openXmlFile(this, path);
    414414
    415415    if (doc == NULL) {
     
    424424    if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) {
    425425
    426         psError(PS_ERR_IO, false, "Root node of XML is not 'tableDescriptions', as it should be");
     426        this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n");
    427427        return false;
    428428    }
     
    445445                table = this->tables+tableNum;
    446446
    447                 if (!loadTableDescription(table, node)) ret = false;
     447                if (!loadTableDescription(this, table, node)) ret = false;
    448448                else tableNum++;
    449449            }
     
    452452
    453453    if (tableNum != this->numOfTables)
    454         psError(PS_ERR_IO, false, "Mismatch between number of tables expected (%d) and those found (%d)", this->numOfTables, tableNum);
     454        this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum);
    455455
    456456    closeXmlFile(doc);
     
    486486                // column type
    487487                getAttribute(node, "pspsName", buffer);
    488                 column = findColumn(table, buffer);
     488                column = findColumn(this, table, buffer);
    489489
    490490                if (!column) continue;
     
    518518    psStringAppend(&path, "%s/map.xml", this->configsPath);
    519519
    520     xmlDoc* doc = openXmlFile(path);
     520    xmlDoc* doc = openXmlFile(this, path);
    521521
    522522    if (doc == NULL) {
     
    529529
    530530    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    531         psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");
     531        this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
    532532        return false;
    533533    }
     
    560560    psStringAppend(&path, "%s/data.xml", this->configsPath);
    561561
    562     xmlDoc* doc = openXmlFile(path);
     562    xmlDoc* doc = openXmlFile(this, path);
    563563
    564564    if (doc == NULL) {
     
    571571
    572572    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    573         psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");
     573        this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
    574574        return false;
    575575    }
    576576
    577577    for (uint32_t i=0; i<this->numOfTables; i++) {
    578         if (!populateTable(this->tables+i, rootElement, fitsOut)) {
     578        if (!populateTable(this, this->tables+i, rootElement, fitsOut)) {
    579579            ret = false;
    580580        }
     
    590590  */
    591591static bool populateTableFromFits(
     592        FitsGenerator* this,
    592593        Table* table,
    593594        Fits *fitsIn,
     
    678679
    679680                default:
    680                     psError(PS_ERR_IO, false, "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'", table->columns[i].ippType,
     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,
    681682                            table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName);
    682683                    break;
     
    711712
    712713    if(!createTable(table, fitsOut, nRows)) return false;
    713     return populateTableFromFits(table, fitsIn, fitsOut, nRows, fromHeader);
     714    return populateTableFromFits(this, table, fitsIn, fitsOut, nRows, fromHeader);
    714715}
    715716
     
    733734  Constructor.
    734735  */
    735 FitsGenerator* new_FitsGenerator(const char* path) {
     736FitsGenerator* new_FitsGenerator(Logger* logger, const char* path) {
    736737
    737738    FitsGenerator* this = (FitsGenerator*)calloc(1, sizeof(FitsGenerator));
     
    739740    this->configsPath = NULL;
    740741    psStringAppend(&this->configsPath, path);
     742    this->logger = logger;
    741743
    742744    // method pointers
  • trunk/ippToPsps/src/FitsGenerator.h

    r31025 r31030  
    1313
    1414#include <psmodules.h>
     15
     16#include "Logger.h"
    1517
    1618// column class
     
    5355    Table* tables;
    5456    int numOfTables;
     57    Logger* logger;
    5558
    5659    // methods
     
    6467
    6568// constructor
    66 FitsGenerator* new_FitsGenerator(const char* path);
     69FitsGenerator* new_FitsGenerator(Logger* logger, const char* path);
    6770
    6871#endif // IPPTOPSPS_FITSGENERATOR_H
  • trunk/ippToPsps/src/InitBatch.c

    r31025 r31030  
    5757  Constructor
    5858  */
    59 InitBatch* new_InitBatch(int *argc, char **argv) {
     59InitBatch* new_InitBatch(Logger* logger, int *argc, char **argv) {
    6060
     61    logger->print(logger, MSG_DEBUG, "InitBatch: Constructor\n");
    6162    InitBatch *this = (InitBatch*)calloc(1, sizeof(InitBatch));
    6263
    6364    // call base-class constructor
    64     if (!new_Batch(&this->base)) {
    65 
    66         psError(PS_ERR_IO, false, "Unable to create Batch base-class object");
    67         return this;
    68     }
     65    new_Batch(logger, &this->base);
    6966
    7067    // method pointers
     
    8582    psTimerStart("initbatch");
    8683
    87     ippToPsps_VersionPrint();
     84//    ippToPsps_VersionPrint();
    8885
    8986    int exitCode;
    9087
    91     InitBatch* initBatch = new_InitBatch(&argc, argv);
     88    Logger* logger = new_Logger(NULL);
     89
     90    InitBatch* initBatch = new_InitBatch(logger, &argc, argv);
    9291    initBatch->base.run(initBatch);
    9392    exitCode = initBatch->base.exitCode;
     
    9796    double secs = psTimerMark("initbatch");
    9897
    99     psLogMsg("initbatch", 3, "initbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
     98    logger->print(logger, MSG_INFO, "initbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
    10099            (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
    101100            exitCode,
     
    106105    psTimerStop();
    107106    psLibFinalize();
     107    logger->destroy(logger);
    108108
    109109    return exitCode;
  • trunk/ippToPsps/src/InitBatch.h

    r31011 r31030  
    3131
    3232// constructor
    33 InitBatch *new_InitBatch(int *argc, char **argv);
     33InitBatch *new_InitBatch(Logger *logger, int *argc, char **argv);
    3434
    3535# endif // IPPTOPSPS_INITBATCH_H
  • trunk/ippToPsps/src/InitData.c

    r31015 r31030  
    2828  */
    2929static bool getRowAttribute(
     30        InitData* this,
    3031        xmlNode* tableNode,
    3132        const char* keyName,
     
    5859    }
    5960
    60     psError(PS_ERR_UNKNOWN,
    61             false,
    62             "* InitData: Could not find value for '%s' for '%s' with value '%s'",
     61    this->logger->print(this->logger, MSG_ERROR,
     62            "InitData: Could not find value for '%s' for '%s' with value '%s'\n",
    6363            attName, keyName, keyValue);
    6464
     
    8383
    8484    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    85         psError(PS_ERR_IO, false, "* InitData: Root node of XML is not 'tabledata', as it should be");
     85        this->logger->print(this->logger, MSG_ERROR,
     86                "InitData: Root node of XML is not 'tabledata', as it should be\n");
    8687        return false;
    8788    }
     
    9899            if (strcmp(tempStr, tableName)!=0) continue;
    99100
    100             ret = getRowAttribute(node, keyName, keyValue, attName, attValue);
     101            ret = getRowAttribute(this, node, keyName, keyValue, attName, attValue);
    101102            break;
    102103        }
     
    155156    }
    156157
    157     psLogMsg("ippToPsps", PS_LOG_INFO, "* InitData: destructor");
     158    this->logger->print(this->logger, MSG_DEBUG, "InitData: destructor\n");
    158159
    159160    free(this);
     
    163164  Constructor.
    164165  */
    165 InitData* new_InitData(const char* path) {
     166InitData* new_InitData(const char* path, Logger* logger) {
    166167
    167     psLogMsg("ippToPsps", PS_LOG_INFO, "* InitData: constructor");
     168
    168169
    169170    InitData* this = (InitData*)calloc(1, sizeof(InitData));
     171    this->logger = logger;
     172
     173    this->logger->print(this->logger, MSG_DEBUG, "InitData: Constructor\n");
    170174
    171175    sprintf(this->path, "%s/init/data.xml", path);
    172176
    173177    this->doc = xmlReadFile(this->path, NULL, 0);
    174     if (this->doc == NULL) psError(PS_ERR_IO, false, "* InitData: Unable to open XML file at %s", this->path);
     178    this->logger->print(this->logger, MSG_ERROR,
     179            "InitData: Unable to open XML file at %s\n", this->path);
    175180
    176181    // method pointers
  • trunk/ippToPsps/src/InitData.h

    r31015 r31030  
    1717#include <psmodules.h>
    1818
     19#include "Logger.h"
     20
    1921/**
    2022
     
    2729    char path[1000];
    2830    xmlDoc* doc;
     31    Logger* logger;
    2932
    3033    // methods
     
    3841
    3942// constructor
    40 InitData* new_InitData(const char* path);
     43InitData* new_InitData(const char* path, Logger* logger);
    4144
    4245#endif // IPPTOPSPS_INITDATA_H
  • trunk/ippToPsps/src/Makefile.am

    r31025 r31030  
    3333        Fits.c \
    3434        InitData.c \
     35        Logger.c \
    3536        FitsGenerator.c
    3637
     
    4445        Fits.c \
    4546        InitData.c \
     47        Logger.c \
    4648        FitsGenerator.c
    4749
     
    5557        Fits.c \
    5658        InitData.c \
     59        Logger.c \
    5760        FitsGenerator.c
    5861
  • trunk/ippToPsps/src/StackBatch.c

    r31025 r31030  
    6262    long unmatched = 0, totalDetections = 0, numOfDuplicates = 0, numInvalidFlux = 0, numDetectionsOut = 0;
    6363
     64    this->base.logger->print(this->base.logger, MSG_INFO,
     65            "+---------------+---------+----------+------------------+---------------+--------------+\n");
     66    this->base.logger->print(this->base.logger, MSG_INFO,
     67            "|   Extension   | Rows in | Rows out | Missing from DVO | Duplicate IDs | Invalid Flux |\n");
     68
    6469    for (long s=0; s<nDet; s++) {
    6570
     
    102107
    103108    }
    104     psLogMsg("ippToPsps", PS_LOG_INFO,
    105             "+---------------+---------+----------+------------------+---------------+--------------+\n"
    106             "|   Extension   | Rows in | Rows out | Missing from DVO | Duplicate IDs | Invalid Flux |\n"
     109
     110    this->base.logger->print(this->base.logger, MSG_INFO,
    107111            "|  %12s |  %5ld  |   %5ld  |      %5ld       |    %5ld      |    %5ld     |\n",
    108112            extensionName, nDet, numDetectionsOut, unmatched, numOfDuplicates, numInvalidFlux);
     113    this->base.logger->print(this->base.logger, MSG_INFO,
     114            "+---------------+---------+----------+------------------+---------------+--------------+\n");
    109115
    110116
     
    315321
    316322    // open input FITS file
    317     Fits* fitsIn = existing_Fits(this->base.inputFiles[0]);
     323    Fits* fitsIn = existing_Fits(this->base.inputFiles[0], this->base.logger);
    318324    if (fitsIn->getFilePtr(fitsIn) == NULL)  return PS_EXIT_SYS_ERROR;
    319325
     
    425431  Constructor
    426432  */
    427 StackBatch* new_StackBatch(int *argc, char **argv) {
    428 
     433StackBatch* new_StackBatch(Logger* logger, int *argc, char **argv) {
     434
     435    logger->print(logger, MSG_DEBUG, "StackBatch: Constructor\n");
    429436    StackBatch *this = (StackBatch*)calloc(1, sizeof(StackBatch));
    430437
    431438    // call base-class constructor
    432     if (!new_Batch(&this->base)) {
    433 
    434         psError(PS_ERR_IO, false, "Unable to create Batch base-class object");
    435         return this;
    436     }
     439    new_Batch(logger, &this->base);
    437440
    438441    this->MAXDETECT = 150000;
     
    455458    psTimerStart("stackbatch");
    456459
    457     ippToPsps_VersionPrint();
     460//    ippToPsps_VersionPrint();
    458461
    459462    int exitCode;
    460463
    461     StackBatch* stackBatch = new_StackBatch(&argc, argv);
     464    Logger* logger = new_Logger(NULL);
     465
     466    StackBatch* stackBatch = new_StackBatch(logger, &argc, argv);
    462467    stackBatch->base.run(stackBatch);
    463468    exitCode = stackBatch->base.exitCode;
     
    467472    double secs = psTimerMark("stackbatch");
    468473
    469     psLogMsg("stackbatch", 3, "stackbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
     474    logger->print(logger, MSG_INFO, "stackbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",
    470475            (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
    471476            exitCode,
     
    476481    psTimerStop();
    477482    psLibFinalize();
     483    logger->destroy(logger);
    478484
    479485    return exitCode;
  • trunk/ippToPsps/src/StackBatch.h

    r30147 r31030  
    3030} StackBatch;
    3131
    32 StackBatch *new_StackBatch(int *argc, char **argv);
     32StackBatch *new_StackBatch(Logger* logger, int *argc, char **argv);
    3333
    3434# endif // IPPTOPSPS_STACKBATCH_H
Note: See TracChangeset for help on using the changeset viewer.