Changeset 16339 for trunk/psModules/src/config/pmConfig.c
- Timestamp:
- Feb 6, 2008, 11:00:43 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/config/pmConfig.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/config/pmConfig.c
r16231 r16339 463 463 } 464 464 465 // set the log file from the config files or -log argument 466 psString logDest = NULL; 465 // Set logging destination first from command line, second from site configuration 466 psString logDest = NULL; // Logging destination 467 467 argNum = psArgumentGet(*argc, argv, "-log"); 468 468 if (argNum > 0) { … … 470 470 if (argNum >= *argc) { 471 471 psWarning("-log command-line switch provided without the required log destination " 472 "--- ignored. \n");472 "--- ignored."); 473 473 } else { 474 logDest = pmConfigConvertFilename (argv[argNum], config, true); 475 psArgumentRemove(argNum, argc, argv); 476 } 477 } else { 478 // Set logging destination 479 psString tmpName = psMetadataLookupStr(&mdok, config->site, "LOGDEST"); 480 if (mdok && tmpName && strlen(tmpName) > 0) { 481 logDest = pmConfigConvertFilename (tmpName, config, true); 482 } 483 } 484 if (logDest) { 485 if (strcasecmp (logDest, "stdout") && strcasecmp (logDest, "stderr")) { 486 // psMessageDestination takes a target of the form file:location 487 // XXX should we modify psMessageDestination to recognize a plain file? 488 psStringPrepend (&logDest, "file:"); 489 } 490 config->logFD = psMessageDestination(logDest); 491 } 474 logDest = psStringCopy(argv[argNum]); 475 psArgumentRemove(argNum, argc, argv); 476 } 477 } 478 if (!logDest) { 479 logDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->site, "LOGDEST")); 480 } 481 if (logDest) { 482 psString resolved = pmConfigConvertFilename(logDest, config, true); // Resolved filename 483 if (!resolved || strlen(resolved) == 0) { 484 psWarning("Unable to resolve log destination: %s --- ignored", logDest); 485 } else { 486 config->logFD = psMessageDestination(resolved); 487 } 488 psFree(resolved); 489 psFree(logDest); 490 } 492 491 if (!psLogSetDestination(config->logFD)) { 493 psWarning("Unable to set log destination to file number %d (%s) --- ignored", config->logFD, logDest); 494 // XXX make this a fatal error? 495 } 496 psFree (logDest); 492 psError(PS_ERR_IO, false, "Unable to set log destination to file number %d --- ignored", 493 config->logFD); 494 psFree(config); 495 return NULL; 496 } 497 497 498 498 // Set trace levels … … 522 522 523 523 // Set trace destinations 524 psString traceDest = NULL; 524 psString traceDest = NULL; // Trace destination 525 525 argNum = psArgumentGet(*argc, argv, "-tracedest"); 526 526 if (argNum > 0) { … … 530 530 "--- ignored.\n"); 531 531 } else { 532 traceDest = pmConfigConvertFilename (argv[argNum], config, true);532 traceDest = psStringCopy(argv[argNum]); 533 533 psArgumentRemove(argNum, argc, argv); 534 534 } 535 } else { 536 psString tmpName = psMetadataLookupStr(&mdok, config->site, "TRACEDEST"); 537 if (mdok && tmpName && strlen(tmpName) > 0) { 538 traceDest = pmConfigConvertFilename (tmpName, config, true); 539 psTrace("psModules.config", 7, "Setting trace destination to %s\n", traceDest); 540 } 541 } 542 if (traceDest) { 543 if (strcasecmp (traceDest, "stdout") && strcasecmp (traceDest, "stderr")) { 544 // psMessageDestination takes a target of the form file:location 545 // XXX should we modify psMessageDestination to recognize a plain file? 546 psStringPrepend (&traceDest, "file:"); 547 } 548 config->traceFD = psMessageDestination(traceDest); 549 } 550 if (!psTraceSetDestination(config->traceFD)) { 551 psWarning("Unable to set trace destination to file number %d (%s)\n", config->traceFD, traceDest); 552 } 553 psFree (traceDest); 535 } 536 if (!traceDest) { 537 traceDest = psMemIncrRefCounter(psMetadataLookupStr(&mdok, config->site, "TRACEDEST")); 538 } 539 if (traceDest) { 540 psString resolved = pmConfigConvertFilename(traceDest, config, true); // Resolved filename 541 if (!resolved || strlen(resolved) == 0) { 542 psWarning("Unable to resolve trace destination: %s --- ignored", traceDest); 543 } else { 544 config->traceFD = psMessageDestination(resolved); 545 } 546 psFree(resolved); 547 psFree(traceDest); 548 } 549 if (!psLogSetDestination(config->traceFD)) { 550 psError(PS_ERR_IO, false, "Unable to set trace destination to file number %d --- ignored", 551 config->traceFD); 552 psFree(config); 553 return NULL; 554 } 554 555 555 556 // Allow command line options to override defaults for logging. … … 1060 1061 } 1061 1062 } else { 1062 // XXX have to be careful with this construction: it catches other errors cluttering up the stack...1063 // XXX have to be careful with this construction: it catches other errors cluttering up the stack... 1063 1064 psErr *error = psErrorLast(); 1064 1065 if (error->code != PS_ERR_NONE) {
Note:
See TracChangeset
for help on using the changeset viewer.
