IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Cleaning up.

File:
1 edited

Legend:

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

    r7300 r7570  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-06-02 21:33:34 $
     11 *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-06-15 00:21:57 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5454
    5555static p_psComponent* cRoot = NULL; // The root of the trace component
    56 // static FILE *traceFP = NULL;        // File destination for messages.
    5756static psBool traceTime = false;     // Flag to include time info
    5857static psBool traceHost = false;     // Flag to include host info
     
    445444    } else {
    446445        if (comp->level == PS_DEFAULT_TRACE_LEVEL) {
    447             // fprintf(traceFP,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, defLevel);
    448446            sprintf(line,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, defLevel);
    449447            write (traceFD, line, strlen(line));
    450448        } else {
    451             // fprintf(traceFP, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, comp->level);
    452449            sprintf(line, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, comp->level);
    453450            write (traceFD, line, strlen(line));
     
    576573        *head_ptr = '\0';
    577574
    578 
    579         // fputs(head, traceFP);
    580575        write (traceFD, head, strlen(head));
    581576
     
    590585            // We indent each message one space for each level of the message.
    591586            for (i = 0; i < level; i++) {
    592                 //            fprintf(traceFP, " ");
    593                 // fprintf(traceFP, "%s", format);
    594                 // sprintf(line, "%s", format);
    595587                write (traceFD, " ", 1);
    596588            }
    597             // vfprintf(traceFP, fmt, ap);
    598589            vsprintf(line, format, ap);
    599590            write (traceFD, line, strlen(line));
     
    601592                write(traceFD, "\n", 1);
    602593            }
    603 
    604 
    605             //        vfprintf(traceFP, format, ap);
    606             //        va_end(ap);
    607             /*            char msg[1024];
    608                         char* msgPtr;
    609                         vsnprintf(msg,1024, format, ap);  // create message
    610 
    611                         // detect multiple lines in message and indent each line by 4 spaces.
    612                         char* line = strtok_r(msg,"\n",&msgPtr);
    613                         while (line != NULL) {
    614                             fprintf(logDest,"    %s\n",line);
    615                             line = strtok_r(NULL,"\n",&msgPtr);
    616                         }
    617             */
    618594        } else {
    619             // fputc('\n', traceFP);
    620595            write(traceFD, "\n", 1);
    621596        }
     
    654629}
    655630
    656 // XXX EAM : I've added code to close the old traceFP (safely)
    657 void psTraceSetDestination(int fd)
    658 {
    659 
    660 
    661     /*
    662         bool special;
    663 
    664         // XXX EAM perhaps return an error?
    665         if (fp == NULL) {
    666             return;
    667         }
    668 
    669         // cannot close traceFP if one of the special FILE ptrs
    670         special  = (traceFP == NULL);
    671         special |= (traceFP == stdin);
    672         special |= (traceFP == stdout);
    673         special |= (traceFP == stderr);
    674 
    675         if (!special) {
    676             fclose (traceFP);
    677         }
    678         traceFP = fp;
    679     */
    680     if (fd < 1) {
    681         traceFD = 0;
     631bool psTraceSetDestination(int fd)
     632{
     633    if (fd < 0) {
    682634        return;
    683635    }
    684     if (fd == 1) {
    685         traceFD = STDOUT_FILENO;
    686     } else if (fd == 2) {
    687         traceFD = STDERR_FILENO;
    688     } else if (fd > 2) {
    689         close (traceFD);
    690         traceFD = fd;
    691     }
     636
     637    if (traceFD > STDERR_FILENO) {
     638        close(traceFD);
     639    }
     640    traceFD = fd;
    692641}
    693642
Note: See TracChangeset for help on using the changeset viewer.