~ubuntu-branches/ubuntu/trusty/sblim-sfcb/trusty-proposed

« back to all changes in this revision

Viewing changes to trace.c

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2009-06-08 12:04:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090608120449-byfplk09rqz8rtg6
Tags: 1.3.3-0ubuntu1
* New upstream release.
* debian/rules: Removed rpath hacks, SFCB default build handles that now.
* Removed 1934753-remove-assignment.diff, now upstream.
* Refreshed patch cim-schema-location.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <sys/resource.h>
34
34
#include <sys/types.h>
35
35
#include <unistd.h>
 
36
#include <pthread.h>
36
37
#include "config.h"
37
38
 
38
39
/* ---------------------------------------------------------------------------*/
48
49
unsigned long _sfcb_trace_mask = 0;
49
50
char *_SFCB_TRACE_FILE = NULL;
50
51
 
51
 
 
52
52
TraceId traceIds[]={ 
53
53
  {"providerMgr",       TRACE_PROVIDERMGR},
54
54
  {"providerDrv",       TRACE_PROVIDERDRV},
137
137
char *_sfcb_format_trace(char *fmt, ...)
138
138
{
139
139
   va_list ap;
140
 
   char *msg = (char *) malloc(1024);
 
140
   char *msg = (char *) malloc(MAX_MSG_SIZE);
141
141
   va_start(ap, fmt);
142
 
   vsnprintf(msg, 1024, fmt, ap);
 
142
   vsnprintf(msg, MAX_MSG_SIZE, fmt, ap);
143
143
   va_end(ap);
144
144
   return msg;
145
145
}
176
176
 
177
177
   if (colorTrace) {
178
178
     changeTextColor(0);
179
 
     fprintf(ferr, "[%i] [%s] %d --- %s(%i) : %s\n", level, tm, currentProc, file,
 
179
     fprintf(ferr, "[%i] [%s] %d/%p --- %s(%i) : %s\n", level, tm, currentProc, (void *)pthread_self(), file,
180
180
             line, msg);
181
181
     changeTextColor(1);
182
182
   }
183
183
   else {
184
 
     fprintf(ferr, "[%i] [%s] %d --- %s(%i) : %s\n", level, tm, currentProc, file,
 
184
     fprintf(ferr, "[%i] [%s] %d/%p --- %s(%i) : %s\n", level, tm, currentProc, (void *)pthread_self(), file,
185
185
             line, msg);
186
186
   }
187
187
 
240
240
 
241
241
   return oldh.sa_handler;
242
242
}
 
243
 
 
244
#ifdef UNITTEST
 
245
// Embedded unittest routine
 
246
int trace_test()
 
247
{
 
248
    int fail=0;
 
249
    _sfcb_trace_start(1);
 
250
    if (_sfcb_debug < 1 ) {
 
251
        printf("  _sfcb_trace_start() test failed.\n");
 
252
        fail=1;
 
253
    }
 
254
    _sfcb_trace_stop();
 
255
    if (_sfcb_debug != 0  ) {
 
256
        printf("  _sfcb_trace_stop() test failed.\n");
 
257
        fail=1;
 
258
    }
 
259
    _sfcb_trace_init();
 
260
    if (_SFCB_TRACE_FILE = NULL  ) {
 
261
        printf("  _sfcb_trace_init() test failed.\n");
 
262
        fail=1;
 
263
    }
 
264
    int num=99;
 
265
    char *msg=_sfcb_format_trace("%s %d","Test message",num);
 
266
    if (strcmp(msg,"Test message 99")) {
 
267
        printf("  _sfcb_format_trace() test failed, message=%s.\n",msg);
 
268
        fail=1;
 
269
    }
 
270
    
 
271
    
 
272
    return fail;
 
273
}
 
274
#endif
 
275