Changeset 1991 for trunk/packages


Ignore:
Timestamp:
Dec 8, 2010, 6:06:20 PM (14 years ago)
Author:
gah
Message:

Clean up debugging/printing traces

Location:
trunk/packages/vizservers/nanovis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/PerfQuery.h

    r1984 r1991  
    3232                    &bitsSupported);
    3333    if(bitsSupported == 0) {
    34         TRACE("occlusion query not supported!\n");
     34        INFO("occlusion query not supported!\n");
    3535        return false;
    3636    } else {
    37         TRACE("Occlusion query with %d bits supported\n", bitsSupported);
     37        INFO("Occlusion query with %d bits supported\n", bitsSupported);
    3838        return true;
    3939    }
  • trunk/packages/vizservers/nanovis/Trace.cpp

    r1984 r1991  
     1
    12#include "nanovis.h"
    23#include <Trace.h>
     
    67#include <GL/glew.h>
    78#include <GL/glut.h>
    8 
    9 static bool trace = false;
     9#include <syslog.h>
    1010
    1111void
    12 PrintMessage(const char *mesg, const char *fileName, int lineNum,
    13              const char* format, ...)
     12LogMessage(int priority, const char *path, int lineNum, const char* fmt, ...)
    1413{
    15     char buff[1024];
     14#define MSG_LEN (2047)
     15    char message[MSG_LEN+1];
     16    const char *s;
     17    int length;
    1618    va_list lst;
    17     FILE *f;
    1819
    19     f = NanoVis::logfile;
    20     if (f == NULL) {
    21         f = stderr;
     20    va_start(lst, fmt);
     21    s = strrchr(path, '/');
     22    if (s == NULL) {
     23        s = path;
     24    } else {
     25        s++;
    2226    }
    23     va_start(lst, format);
    24     vsnprintf(buff, 1023, format, lst);
    25     buff[1023] = '\0';
    26     fprintf(f, "%s at line %d of \"%s\": %s\n", mesg, lineNum, fileName, buff);
    27     fflush(f);
     27    length = snprintf(message, MSG_LEN, "line %d of \"%s\": ", lineNum, s);
     28    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
     29    message[MSG_LEN] = '\0';
     30    syslog(priority, message, length);
    2831}
    2932
  • trunk/packages/vizservers/nanovis/Trace.h

    r1984 r1991  
    44#include <GL/glew.h>
    55#include <GL/glut.h>
     6#include <syslog.h>
    67
    78#define MAKE_STRING(x) #x
     
    910#define AT __FILE__ ":" NEWSTRING(__LINE__)
    1011
    11 extern void PrintMessage(const char *mesg, const char *fileName, int lineNum,
     12extern void LogMessage(int priority, const char *fileName, int lineNum,
    1213                         const char* format, ...);
    1314
    14 #define ERROR(...)      PrintMessage("Error", __FILE__, __LINE__, __VA_ARGS__)
     15#define ERROR(...)      LogMessage(LOG_ERR, __FILE__, __LINE__, __VA_ARGS__)
    1516#ifdef WANT_TRACE
    16 #define TRACE(...)      PrintMessage("Trace", __FILE__, __LINE__, __VA_ARGS__)
     17#define TRACE(...)      LogMessage(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
    1718#else
    1819#define TRACE(...)
    1920#endif
    20 #define WARN(...)       PrintMessage("Warning", __FILE__, __LINE__, __VA_ARGS__)
    21 #define INFO(...)       PrintMessage("Info", __FILE__, __LINE__, __VA_ARGS__)
     21#define WARN(...)       LogMessage(LOG_WARNING, __FILE__, __LINE__, __VA_ARGS__)
     22#define INFO(...)       LogMessage(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
    2223
    2324
  • trunk/packages/vizservers/nanovis/global.h

    r1984 r1991  
    106106system_info()
    107107{
    108     TRACE("-----------------------------------------------------------\n");
    109     TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
     108    INFO("-----------------------------------------------------------\n");
     109    INFO("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
    110110           glGetString(GL_VERSION));
    111     TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER));
    112     TRACE("-----------------------------------------------------------\n");
     111    INFO("Graphics hardware: %s\n", glGetString(GL_RENDERER));
     112    INFO("-----------------------------------------------------------\n");
    113113}
    114114
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r1984 r1991  
    397397    WriteStats("nanovis", code);
    398398#endif
     399    closelog();
    399400    exit(code);
    400401}
     
    769770{
    770771    // print system information
    771     TRACE("-----------------------------------------------------------\n");
    772     TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
     772    INFO("-----------------------------------------------------------\n");
     773    INFO("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
    773774           glGetString(GL_VERSION));
    774     TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER));
    775     TRACE("-----------------------------------------------------------\n");
     775    INFO("Graphics hardware: %s\n", glGetString(GL_RENDERER));
     776    INFO("-----------------------------------------------------------\n");
    776777    if (path == NULL) {
    777778        ERROR("No path defined for shaders or resources\n");
     
    784785        //assert(false);
    785786    }
    786     TRACE("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
     787    INFO("Using GLEW %s\n", glewGetString(GLEW_VERSION));
    787788
    788789    if (!R2FilePath::getInstance()->setPath(path)) {
     
    22482249    path = NULL;
    22492250    NanoVis::stdin = stdin;
    2250     NanoVis::logfile = stderr;
    2251 
     2251
     2252    openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID,  LOG_USER);
    22522253    gettimeofday(&tv, NULL);
    22532254    stats.start = tv;
     
    22762277        static struct option long_options[] = {
    22772278            {"infile",  required_argument, NULL,           0},
    2278             {"logfile", required_argument, NULL,           1},
    22792279            {"path",    required_argument, NULL,           2},
    22802280            {"debug",   no_argument,       NULL,           3},
     
    23172317            }
    23182318            break;
    2319         case 1:
    2320         case 'l':
    2321             NanoVis::logfile = fopen(optarg, "w");
    2322             if (NanoVis::logfile == NULL) {
    2323                 perror(optarg);
    2324                 return 2;
    2325             }
    2326             break;
    23272319        case 4:
    23282320        case 'r':
Note: See TracChangeset for help on using the changeset viewer.