ICU-2403 tracing, more changes from code review

X-SVN-Rev: 13797
This commit is contained in:
Andy Heninger 2003-11-21 00:41:07 +00:00
parent 55c052a7e8
commit 6d106efab7
4 changed files with 23 additions and 18 deletions

View File

@ -78,12 +78,13 @@ UTraceEntry(const void *context, int32_t fnNumber);
* Type signature for the trace function to be called when exiting from a function.
* @param context value supplied at the time the trace functions are set.
* @param fnNumber Enum value indicating the ICU function being exited.
* @param retType the UTraceExitVal indicating the number and types of
* variable arguments that follow.
* @param argType values returned by the function being traced, may include
* one or both of the function's return value and a
* UErrorCode parameter value.
* @see UTraceExitVal
* @param fmt A formatting string that describes the number and types
* of arguments included with the variable args. The fmt
* string has the same form as the utrace_vformat format
* string.
* @param args A variable arguments list. Contents are described by
* the fmt parameter.
* @see utrace_vformat
* @draft ICU 2.8
*/
typedef void U_CALLCONV
@ -93,8 +94,12 @@ UTraceExit(const void *context, int32_t fnNumber,
/**
* Type signature for the trace function to be called from within an ICU function
* to display data or messages.
* @param context value supplied at the time the trace functions are set.
* @param context value supplied at the time the trace functions are set.
* @param fnNumber Enum value indicating the ICU function being exited.
* @param level The current tracing level
* @param fmt A format string describing the tracing data that is supplied
* as variable args
* @param args The data being traced, passed as variable args.
* @draft ICU 2.8
*/
typedef void U_CALLCONV
@ -266,14 +271,14 @@ utrace_getFunctions(const void **context,
* @draft ICU 2.8
*/
U_CAPI int32_t U_EXPORT2
utrace_format(char *outBuf, int32_t capacity,
utrace_vformat(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, va_list args);
/**
* Trace output Formatter. An application's UTraceData tracing functions may call
* this function to format any additional trace data, beyond that
* provided by default, in human readable form with the same
* formatting conventions used by utrace_format().
* formatting conventions used by utrace_vformat().
* @param outBuf pointer to a buffer to receive the formatted output. Output
* will be nul terminated if there is space in the buffer -
* if the length of the requested output < the output buffer size.
@ -287,7 +292,7 @@ utrace_format(char *outBuf, int32_t capacity,
* @draft ICU 2.8
*/
U_CAPI int32_t U_EXPORT2
utrace_formatA(char *outBuf, int32_t capacity,
utrace_format(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, ...);

View File

@ -184,7 +184,7 @@ static void outputUString(const UChar *s, int32_t len,
}
U_CAPI int32_t U_EXPORT2
utrace_format(char *outBuf, int32_t capacity, int32_t indent, const char *fmt, va_list args) {
utrace_vformat(char *outBuf, int32_t capacity, int32_t indent, const char *fmt, va_list args) {
int32_t outIx = 0;
int32_t fmtIx = 0;
int32_t tbufIx = 0;
@ -384,12 +384,12 @@ utrace_format(char *outBuf, int32_t capacity, int32_t indent, const char *fmt, v
U_CAPI int32_t U_EXPORT2
utrace_formatA(char *outBuf, int32_t capacity,
utrace_format(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, ...) {
int32_t retVal;
va_list args;
va_start(args, fmt );
retVal = utrace_format(outBuf, capacity, indent, fmt, args);
retVal = utrace_vformat(outBuf, capacity, indent, fmt, args);
va_end(args);
return retVal;
}

View File

@ -65,7 +65,7 @@ void ctest_setICU_DATA(void);
static int traceFnNestingDepth = 0;
void U_CALLCONV TraceEntry(const void *context, int32_t fnNumber) {
char buf[500];
utrace_formatA(buf, sizeof(buf), traceFnNestingDepth*3, "%s() enter.\n", utrace_functionName(fnNumber));
utrace_format(buf, sizeof(buf), traceFnNestingDepth*3, "%s() enter.\n", utrace_functionName(fnNumber));
fputs(buf, stdout);
traceFnNestingDepth++;
}
@ -76,9 +76,9 @@ void U_CALLCONV TraceExit(const void *context, int32_t fnNumber, const char *fmt
if (traceFnNestingDepth>0) {
traceFnNestingDepth--;
}
utrace_formatA(buf, sizeof(buf), traceFnNestingDepth*3, "%s() ", utrace_functionName(fnNumber));
utrace_format(buf, sizeof(buf), traceFnNestingDepth*3, "%s() ", utrace_functionName(fnNumber));
fputs(buf, stdout);
utrace_format(buf, sizeof(buf), traceFnNestingDepth*3, fmt, args);
utrace_vformat(buf, sizeof(buf), traceFnNestingDepth*3, fmt, args);
fputs(buf, stdout);
putc('\n', stdout);
}
@ -86,7 +86,7 @@ void U_CALLCONV TraceExit(const void *context, int32_t fnNumber, const char *fmt
void U_CALLCONV TraceData(const void *context, int32_t fnNumber,
int32_t level, const char *fmt, va_list args) {
char buf[500];
utrace_format(buf, sizeof(buf), traceFnNestingDepth*3, fmt, args);
utrace_vformat(buf, sizeof(buf), traceFnNestingDepth*3, fmt, args);
fputs(buf, stdout);
putc('\n', stdout);
}

View File

@ -77,7 +77,7 @@ static void test_format(const char *format, int32_t bufCap, int32_t indent,
/* run the formatter */
va_start(args, line);
memset(buf, 0, sizeof(buf));
len = utrace_format(buf, bufCap, indent, format, args);
len = utrace_vformat(buf, bufCap, indent, format, args);
/* Check results. */
if (strcmp(expectedResult, buf) != 0) {