Exemplo n.º 1
0
void TraceOut(long TraceOption, char *text, ...)
{
	char buffer[DEBUG_BUFFER_SIZE*2]; // double the size to 4096
	char *p;
	int  rc = 0;

	if (IsTraceLibrary())
	{
		if (pdwGlobalTraceVariable == NULL) 
			InitializeTrace();
		if (pdwGlobalTraceVariable && *pdwGlobalTraceVariable && (gTraceFlags & TraceOption))
		{
			if (fpTraceDebugOut)
			{
				p = (char *)&text + (long) sizeof (char *);   // Get VA_ARG pointer    
				rc = _vsnprintf(buffer, DEBUG_BUFFER_SIZE*2, text, p);
				if (rc == -1) /* if truncation happened, errno will be set to 34 */
					errno = 0;/* need to reset it back to 0, otherwise ctosqlconv may fail when */
				              /* converting numeric due to errno already set */
			
				fpTraceDebugOut(strlen(buffer), buffer, TraceOptionToString(TraceOption), FORMAT_TEXT);
			}
		}
	}
	else
		RESET_TRACE()
	return;
}
Exemplo n.º 2
0
void PrintTraceLine(const char* function, const char* source_file, const int source_line, const TRACE_ERRORLEVEL level, const char* format, ...)
{
  va_list vl;
  va_start(vl, format);
  static char timestamp[__MAX_TRACE_TIMESTAMP_LENGTH];  

  if (!_trace_initialized)
  {
    InitializeTrace();
  } 

  if (level <= _trace_level)
  {
    time_t t;    
    struct tm *tmp;
    time(&t);
    tmp = localtime(&t);
    strftime(timestamp, sizeof(timestamp), "%Y.%m.%d %H:%M:%S", tmp);
    fprintf(_trace_file, "[%s] %s ", timestamp, GetLevelString(level));
    fprintf(_trace_file, "<%s> (%s:%d) > ", function, source_file, source_line);
    vfprintf(_trace_file, format, vl);
    fprintf(_trace_file, "\n");
    fflush(_trace_file);
  }
}
Exemplo n.º 3
0
void HexOut(long TraceOption, SQLLEN* len, void* buffer, char *text )
{
	if (IsTraceLibrary())
	{
		InitializeTrace();
		if (pdwGlobalTraceVariable && *pdwGlobalTraceVariable && (gTraceFlags & TraceOption))
		{
			if (fpTraceDebugOut)
			{
				if( buffer != NULL && len != NULL && text != NULL)
				{
					if( *len > 0 )
					{
						fpTraceDebugOut(*len % 500, (char*)buffer, text, FORMAT_DUMP);
					}
				}
			}
		}
	}
	else
		RESET_TRACE()
	return;
}