IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 24, 2008, 5:46:45 PM (18 years ago)
Author:
eugene
Message:

fix the log/trace to work with file://, path://, neb://

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r16028 r16231  
    463463        }
    464464
     465        // set the log file from the config files or -log argument
     466        psString logDest = NULL;
    465467        argNum = psArgumentGet(*argc, argv, "-log");
    466468        if (argNum > 0) {
     
    470472                          "--- ignored.\n");
    471473            } else {
    472                 config->logFD = psMessageDestination(argv[argNum]);
    473                 psArgumentRemove(argNum, argc, argv);
     474                logDest = pmConfigConvertFilename (argv[argNum], config, true);
     475                psArgumentRemove(argNum, argc, argv);
    474476            }
    475477        } else {
    476478            // Set logging destination
    477             psString logDest = psMetadataLookupStr(&mdok, config->site, "LOGDEST");
    478             if (mdok && logDest && strlen(logDest) > 0) {
    479                 config->logFD = psMessageDestination(logDest);
    480             }
    481         }
     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        }
    482492        if (!psLogSetDestination(config->logFD)) {
    483             psWarning("Unable to set log destination to file number %d --- ignored", config->logFD);
    484         }
     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);
    485497
    486498        // Set trace levels
     
    510522
    511523        // Set trace destinations
     524        psString traceDest = NULL;
    512525        argNum = psArgumentGet(*argc, argv, "-tracedest");
    513526        if (argNum > 0) {
     
    517530                          "--- ignored.\n");
    518531            } else {
    519                 config->traceFD = psMessageDestination(argv[argNum]);
     532                traceDest = pmConfigConvertFilename (argv[argNum], config, true);
    520533                psArgumentRemove(argNum, argc, argv);
    521534            }
    522535        } else {
    523             psString traceDest = psMetadataLookupStr(&mdok, config->site, "TRACEDEST");
    524             if (mdok && traceDest && strlen(traceDest) > 0) {
     536            psString tmpName = psMetadataLookupStr(&mdok, config->site, "TRACEDEST");
     537            if (mdok && tmpName && strlen(tmpName) > 0) {
     538                traceDest = pmConfigConvertFilename (tmpName, config, true);
    525539                psTrace("psModules.config", 7, "Setting trace destination to %s\n", traceDest);
    526                 config->traceFD = psMessageDestination(traceDest);
    527             }
    528         }
     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        }
    529550        if (!psTraceSetDestination(config->traceFD)) {
    530             psWarning("Unable to set log destination to file %d\n", config->traceFD);
    531         }
     551            psWarning("Unable to set trace destination to file number %d (%s)\n", config->traceFD, traceDest);
     552        }
     553        psFree (traceDest);
    532554
    533555        // Allow command line options to override defaults for logging.
Note: See TracChangeset for help on using the changeset viewer.