IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7576


Ignore:
Timestamp:
Jun 14, 2006, 4:24:19 PM (20 years ago)
Author:
Paul Price
Message:

Adding command-line log destination.

File:
1 edited

Legend:

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

    r7528 r7576  
    33 *  @author PAP, IfA
    44 *
    5  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-06-13 02:39:27 $
     5 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-15 02:24:19 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    258258                     "-camera command-line switch provided without the required filename --- ignored.\n");
    259259        } else {
     260            readConfig(&config->camera, argv[argNum], "camera");
    260261            psArgumentRemove(argNum, argc, argv);
    261             readConfig(&config->camera, argv[argNum], "camera");
    262262        }
    263263    }
     
    310310
    311311
    312     //
    313     // If LOGDEST is specified in the configuration file, then we must initialize
    314     // with a call to psLogSetDestination().
    315     // XXX: This is not spec'ed in the SDRS.
    316     //
    317     psString logDest = psMetadataLookupStr(&mdok, config->site, "LOGDEST");
    318     if (mdok && logDest) {
    319         // XXX: Only stdout and stderr are provided for now; this section should be
    320         // expanded in the future to do files, and perhaps even sockets.
    321         int logFD = STDIN_FILENO; // a known invalid value
    322         if (!strcasecmp(logDest, "STDOUT")) {
    323             logFD = STDOUT_FILENO;
    324         }
    325         if (!strcasecmp(logDest, "STDERR")) {
    326             logFD = STDERR_FILENO;
    327         }
    328         if (logFD == STDIN_FILENO) {
    329             psLogMsg(__func__, PS_LOG_WARN, "Only STDERR and STDOUT currently supported as a log "
    330                      "destination.\n");
    331             logFD = STDERR_FILENO;
    332         }
    333         psTrace(__func__, 7, "Setting log destination to STDOUT.\n");
    334         psLogSetDestination(logFD);
     312    argNum = psArgumentGet(*argc, argv, "-log");
     313    if (argNum > 0) {
     314        psArgumentRemove(argNum, argc, argv);
     315        if (argNum >= *argc) {
     316            psLogMsg(__func__, PS_LOG_WARN,
     317                     "-log command-line switch provided without the required log destination --- ignored.\n");
     318        } else {
     319            if (!psLogSetDestination(psMessageDestination(argv[argNum]))) {
     320                psLogMsg(__func__, PS_LOG_WARN, "Unable to set log destination to %s\n", argv[argNum]);
     321            }
     322            psArgumentRemove(argNum, argc, argv);
     323        }
     324    } else {
     325        //
     326        // If LOGDEST is specified in the configuration file, then we must initialize
     327        // with a call to psLogSetDestination().
     328        // XXX: This is not spec'ed in the SDRS.
     329        //
     330        psString logDest = psMetadataLookupStr(&mdok, config->site, "LOGDEST");
     331        if (mdok && logDest && strlen(logDest) > 0) {
     332            // XXX: Only stdout and stderr are provided for now; this section should be
     333            // expanded in the future to do files, and perhaps even sockets.
     334            if (!!psLogSetDestination(psMessageDestination(argv[argNum]))) {
     335                psLogMsg(__func__, PS_LOG_WARN, "Unable to set log destination to %s\n", argv[argNum]);
     336            }
     337        }
    335338    }
    336339
Note: See TracChangeset for help on using the changeset viewer.