Changeset 31036
- Timestamp:
- Mar 24, 2011, 1:21:35 PM (15 years ago)
- Location:
- trunk/ippToPsps/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/Batch.c
r31033 r31036 113 113 while (fgets(line, 1000, file) != NULL) this->numOfInputFiles++; 114 114 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", 116 "%d input file%s found\n", this->numOfInputFiles, (this->numOfInputFiles > 1) ? "s" : ""); 116 117 117 118 if (this->numOfInputFiles < 1) return false; … … 256 257 static void print(Batch* this) { 257 258 258 printf("\n"); 259 printf("* surveyType : '%s'\n", this->surveyType); 260 printf("* surveyID : %d\n", this->surveyID); 261 printf("* resultsPath : '%s'\n", this->resultsPath); 262 printf("* numOfInputFiles : %d\n", this->numOfInputFiles); 263 printf("* fitsInPath : '%s'\n", this->fitsInPath); 259 this->logger->print(this->logger, MSG_INFO, "Batch", "\n"); 260 this->logger->print(this->logger, MSG_INFO, "Batch", " Class fields:\n"); 261 this->logger->print(this->logger, MSG_INFO, "Batch", "surveyType : %s\n", this->surveyType); 262 this->logger->print(this->logger, MSG_INFO, "Batch", "surveyID : %d\n", this->surveyID); 263 this->logger->print(this->logger, MSG_INFO, "Batch", "resultsPath : %s\n", this->resultsPath); 264 this->logger->print(this->logger, MSG_INFO, "Batch", "numOfInputFiles : %d\n", this->numOfInputFiles); 265 this->logger->print(this->logger, MSG_INFO, "Batch", "fitsInPath : %s\n", this->fitsInPath); 266 this->logger->print(this->logger, MSG_INFO, "Batch", "testMode : %s\n", this->testMode ? "yes" : "no"); 264 267 } 265 268 -
trunk/ippToPsps/src/Batch.h
r31030 r31036 30 30 - StackBatch 31 31 32 All subclasses need to implement the run() method and may need to imple nent print()32 All subclasses need to implement the run() method and may need to implement print() 33 33 */ 34 34 typedef struct Batch { -
trunk/ippToPsps/src/DetectionBatch.c
r31033 r31036 440 440 this->base.print(&this->base); 441 441 442 printf("*exp ID : %d\n", this->expId);443 printf("* exp name : '%s'\n", this->expName ? this->expName : "undef");444 printf("\n");442 this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "exp ID : %d\n", this->expId); 443 this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "exp name : %s\n", this->expName ? this->expName : "undef"); 444 this->base.logger->print(this->base.logger, MSG_INFO, "DetectionBatch", "\n"); 445 445 } 446 446 … … 518 518 parseArguments(this, *argc, argv); 519 519 520 this->print(this); 521 520 522 return this; 521 523 } … … 528 530 // ippToPsps_VersionPrint(); 529 531 530 Logger* logger = new_Logger(NULL); 532 Logger* logger = new_Logger(NULL, false); 533 // Logger* logger = new_Logger("./detBatchLog.txt", false); 531 534 logger->print(logger, MSG_INFO, "main", "Creating new detection batch\n"); 532 535 -
trunk/ippToPsps/src/Fits.c
r31033 r31036 45 45 } 46 46 else 47 this->logger->print(this->logger, MSG_ INFO, "Fits", "Closed FITS file '%s'\n", this->path);47 this->logger->print(this->logger, MSG_DEBUG, "Fits", "Closed FITS file '%s'\n", this->path); 48 48 49 49 free(this); -
trunk/ippToPsps/src/InitBatch.c
r31033 r31036 50 50 } 51 51 52 53 52 return true; 54 53 } … … 72 71 parseArguments(this, *argc, argv); 73 72 73 this->print(this); 74 74 75 return this; 75 76 } … … 82 83 // ippToPsps_VersionPrint(); 83 84 84 Logger* logger = new_Logger(NULL );85 Logger* logger = new_Logger(NULL, false); 85 86 logger->print(logger, MSG_INFO, "main", "Creating new initialization batch\n"); 86 87 … … 90 91 91 92 initBatch->destroy(initBatch); 92 93 93 94 94 // tidy up -
trunk/ippToPsps/src/Logger.c
r31032 r31036 40 40 static void print(void* this, const int8_t typeInt, const char* class, const char* fmt, ...) { 41 41 42 Logger* logger = (Logger*)this; 43 42 44 va_list args; 43 45 va_start(args, fmt); … … 55 57 break; 56 58 case MSG_DEBUG: 59 if (!logger->showDebug) return; 57 60 sprintf(typeStr, "DEBUG"); 58 61 break; … … 70 73 sprintf(msg_fmt, "%s", fmt); 71 74 else 72 sprintf(msg_fmt, "%1 9s | %6s | %15s | %s ", timeStr, typeStr, class, fmt);75 sprintf(msg_fmt, "%18s | %6s | %15s | %s ", timeStr, typeStr, class, fmt); 73 76 74 Logger* logger = (Logger*)this;75 77 76 78 // write either to file or stdout … … 83 85 84 86 Returns a new Logger object. 87 88 path - path to file where log should be saved, otherwise stdout is used 89 showDebug - show debug messages or not 85 90 */ 86 Logger* new_Logger(const char* path) { 87 91 Logger* new_Logger(const char* path, const int8_t showDebug) { 88 92 89 93 Logger* this = (Logger*)calloc(1, sizeof(Logger)); 90 94 91 95 this->file = NULL; 96 this->showDebug = showDebug; 92 97 gettimeofday(&this->startTime, 0); 93 98 94 99 // open a file to write to 95 if (path != NULL) { 96 97 this->file = fopen(path, "w+"); 98 if (this->file == NULL) 99 print(this, MSG_ERROR, "Logger", "Cannot open file for writing here '%s'\n", path); 100 } 100 if (path != NULL) this->file = fopen(path, "w+"); 101 101 102 102 print(this, MSG_DEBUG, "Logger", "Constructor\n"); 103 print(this, MSG_INFO, "Logger", "Starting timer\n"); 104 105 if (path != NULL) { 106 107 if (this->file == NULL) 108 print(this, MSG_ERROR, "Logger", "Cannot open file for writing here '%s'\n", path); 109 else 110 printf("**** Saving log to '%s'\n", path); 111 } 103 112 104 113 // method pointers -
trunk/ippToPsps/src/Logger.h
r31032 r31036 32 32 FILE* file; 33 33 struct timeval startTime; 34 int8_t showDebug; 34 35 35 36 // methods … … 43 44 44 45 // constructor 45 Logger* new_Logger(const char* path );46 Logger* new_Logger(const char* path, const int8_t showDebug); 46 47 47 48 # endif // IPPTOPSPS_LOGGER_H -
trunk/ippToPsps/src/StackBatch.c
r31033 r31036 386 386 this->base.print(&this->base); 387 387 388 printf("*skycell ID : %d\n", this->skycellId);389 printf("\n");388 this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", "skycell ID : %d\n", this->skycellId); 389 this->base.logger->print(this->base.logger, MSG_INFO, "StackBatch", "\n"); 390 390 } 391 391 … … 454 454 parseArguments(this, *argc, argv); 455 455 456 this->print(this); 457 456 458 return this; 457 459 } … … 464 466 // ippToPsps_VersionPrint(); 465 467 466 int exitCode; 467 468 Logger* logger = new_Logger(NULL); 468 Logger* logger = new_Logger(NULL, false); 469 469 logger->print(logger, MSG_INFO, "main", "Creating new stack batch\n"); 470 470 471 471 StackBatch* stackBatch = new_StackBatch(logger, &argc, argv); 472 472 stackBatch->base.run(stackBatch); 473 exitCode = stackBatch->base.exitCode;473 int exitCode = stackBatch->base.exitCode; 474 474 475 475 stackBatch->destroy(stackBatch);
Note:
See TracChangeset
for help on using the changeset viewer.
