diff options
author | eutarass | 2009-10-01 19:36:19 +0000 |
---|---|---|
committer | eutarass | 2009-10-01 19:36:19 +0000 |
commit | 8b5386e85e1c96823d2691c37eda28483deee6a0 (patch) | |
tree | 88a5d8cd2570053270dbdfff963b64c94bd9d017 | |
parent | 9a5725c8c7aa63a76d09f4a888a2852c4309de13 (diff) | |
download | org.eclipse.tcf.agent-8b5386e85e1c96823d2691c37eda28483deee6a0.tar.gz org.eclipse.tcf.agent-8b5386e85e1c96823d2691c37eda28483deee6a0.tar.xz org.eclipse.tcf.agent-8b5386e85e1c96823d2691c37eda28483deee6a0.zip |
TCF Agent: trace.c - got rid of string buffer by using vfprintf()
-rw-r--r-- | trace.c | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -40,48 +40,42 @@ int print_trace(int mode, char *fmt, ...) { if (log_file == NULL) return 0; if (mode != LOG_ALWAYS && (log_mode & mode) == 0) return 0; + va_start(ap, fmt); if (is_daemon()) { - va_start(ap, fmt); #if defined(WIN32) #elif defined(_WRS_KERNEL) #else vsyslog(LOG_MAKEPRI(LOG_DAEMON, LOG_INFO), fmt, ap); #endif - va_end(ap); - return 1; } else { struct timespec timenow; - char tmpbuf[1000]; if (clock_gettime(CLOCK_REALTIME, &timenow)) { perror("clock_gettime"); exit(1); } - va_start(ap, fmt); - vsnprintf(tmpbuf, sizeof(tmpbuf), fmt, ap); - va_end(ap); - if (pthread_mutex_lock(&mutex) != 0) { perror("pthread_mutex_lock"); exit(1); } - fprintf(log_file, "TCF %02d:%02d.%03d: %s\n", + fprintf(log_file, "TCF %02d:%02d.%03d: ", (int)(timenow.tv_sec / 60 % 60), (int)(timenow.tv_sec % 60), - (int)(timenow.tv_nsec / 1000000), - tmpbuf); + (int)(timenow.tv_nsec / 1000000)); + vfprintf(log_file, fmt, ap); + fprintf(log_file, "\n"); fflush(log_file); if (pthread_mutex_unlock(&mutex) != 0) { perror("pthread_mutex_unlock"); exit(1); } - - return 1; } + va_end(ap); + return 1; } #endif /* ENABLE_Trace */ |