IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7569


Ignore:
Timestamp:
Jun 14, 2006, 2:17:32 PM (20 years ago)
Author:
Paul Price
Message:

Abstracting stdout, stderr file descriptors, just in case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psLogMsg.c

    r7568 r7569  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-06-15 00:14:49 $
     13 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-06-15 00:17:32 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4242#define MAX_LOG_LINE_LENGTH 256
    4343
    44 static int logFD = 2;                   // Log file descriptor
     44static int logFD = STDERR_FILENO;       // Log file descriptor
    4545static psS32 globalLogLevel = PS_LOG_INFO; // log all messages at this or above
    4646static psBool logTime = true;     // Flag to include time info
     
    8787bool psLogSetDestination(int fd)
    8888{
    89     if (fd <= -1) {
     89    if (fd < 0) {
    9090        return false;
    9191    }
    9292
    9393    // Close the current FD if it's not stdout, stderr.
    94     if (logFD > 2) {
     94    if (logFD > STDERR_FILENO) {
    9595        close(logFD);
    9696    }
     
    186186    // Special destinations: stdout, stderr
    187187    if (strcmp(dest, "stdout") == 0) {
    188         return 1;
     188        return STDOUT_FILENO;
    189189    }
    190190    if (strcmp(dest, "stderr") == 0) {
    191         return 2;
     191        return STDERR_FILENO;
    192192    }
    193193
     
    250250    // If it's an abort, we always want to see the message
    251251    if (logFD == 0 && level == PS_LOG_ABORT) {
    252         logFD = 2;
     252        logFD = STDERR_FILENO;
    253253    }
    254254    // If logging is off, or if the level is too high, return immediately.
     
    352352    if (level == PS_LOG_ABORT) {
    353353        switch (logFD) {
    354         case 1:
     354        case STDOUT_FILENO:
    355355            fflush(stdout);
    356356            break;
    357         case 2:
     357        case STDERR_FILENO:
    358358            fflush(stderr);
    359359            break;
Note: See TracChangeset for help on using the changeset viewer.