ICU 77.1  77.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
utrace.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 2003-2013, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: utrace.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2003aug06
16 * created by: Markus W. Scherer
17 *
18 * Definitions for ICU tracing/logging.
19 *
20 */
21 
22 #ifndef __UTRACE_H__
23 #define __UTRACE_H__
24 
25 #include <stdarg.h>
26 #include "unicode/utypes.h"
27 
40 
46 typedef enum UTraceLevel {
60 
65 typedef enum UTraceFunctionNumber {
66  UTRACE_FUNCTION_START=0,
67  UTRACE_U_INIT=UTRACE_FUNCTION_START,
68  UTRACE_U_CLEANUP,
69 
70 #ifndef U_HIDE_DEPRECATED_API
76 #endif // U_HIDE_DEPRECATED_API
77 
78  UTRACE_CONVERSION_START=0x1000,
79  UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,
80  UTRACE_UCNV_OPEN_PACKAGE,
81  UTRACE_UCNV_OPEN_ALGORITHMIC,
82  UTRACE_UCNV_CLONE,
83  UTRACE_UCNV_CLOSE,
84  UTRACE_UCNV_FLUSH_CACHE,
85  UTRACE_UCNV_LOAD,
86  UTRACE_UCNV_UNLOAD,
87 
88 #ifndef U_HIDE_DEPRECATED_API
94 #endif // U_HIDE_DEPRECATED_API
95 
96  UTRACE_COLLATION_START=0x2000,
97  UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,
98  UTRACE_UCOL_CLOSE,
99  UTRACE_UCOL_STRCOLL,
100  UTRACE_UCOL_GET_SORTKEY,
101  UTRACE_UCOL_GETLOCALE,
102  UTRACE_UCOL_NEXTSORTKEYPART,
103  UTRACE_UCOL_STRCOLLITER,
104  UTRACE_UCOL_OPEN_FROM_SHORT_STRING,
107 #ifndef U_HIDE_DEPRECATED_API
113 #endif // U_HIDE_DEPRECATED_API
114 
120 
137 
145 
154 
167 
168 #ifndef U_HIDE_INTERNAL_API
174 #endif // U_HIDE_INTERNAL_API
175 
181 
188 
195 
205 
212 
219 
229 
230 #ifndef U_HIDE_INTERNAL_API
236 #endif // U_HIDE_INTERNAL_API
237 
239 
245 U_CAPI void U_EXPORT2
246 utrace_setLevel(int32_t traceLevel);
247 
253 U_CAPI int32_t U_EXPORT2
255 
256 /* Trace function pointers types ----------------------------- */
257 
264 typedef void U_CALLCONV
265 UTraceEntry(const void *context, int32_t fnNumber);
266 
280 typedef void U_CALLCONV
281 UTraceExit(const void *context, int32_t fnNumber,
282  const char *fmt, va_list args);
283 
295 typedef void U_CALLCONV
296 UTraceData(const void *context, int32_t fnNumber, int32_t level,
297  const char *fmt, va_list args);
298 
327 U_CAPI void U_EXPORT2
328 utrace_setFunctions(const void *context,
329  UTraceEntry *e, UTraceExit *x, UTraceData *d);
330 
341 U_CAPI void U_EXPORT2
342 utrace_getFunctions(const void **context,
343  UTraceEntry **e, UTraceExit **x, UTraceData **d);
344 
345 
346 
347 /*
348  *
349  * ICU trace format string syntax
350  *
351  * Format Strings are passed to UTraceData functions, and define the
352  * number and types of the trace data being passed on each call.
353  *
354  * The UTraceData function, which is supplied by the application,
355  * not by ICU, can either forward the trace data (passed via
356  * varargs) and the format string back to ICU for formatting into
357  * a displayable string, or it can interpret the format itself,
358  * and do as it wishes with the trace data.
359  *
360  *
361  * Goals for the format string
362  * - basic data output
363  * - easy to use for trace programmer
364  * - sufficient provision for data types for trace output readability
365  * - well-defined types and binary portable APIs
366  *
367  * Non-goals
368  * - printf compatibility
369  * - fancy formatting
370  * - argument reordering and other internationalization features
371  *
372  * ICU trace format strings contain plain text with argument inserts,
373  * much like standard printf format strings.
374  * Each insert begins with a '%', then optionally contains a 'v',
375  * then exactly one type character.
376  * Two '%' in a row represent a '%' instead of an insert.
377  * The trace format strings need not have \n at the end.
378  *
379  *
380  * Types
381  * -----
382  *
383  * Type characters:
384  * - c A char character in the default codepage.
385  * - s A NUL-terminated char * string in the default codepage.
386  * - S A UChar * string. Requires two params, (ptr, length). Length=-1 for nul term.
387  * - b A byte (8-bit integer).
388  * - h A 16-bit integer. Also a 16 bit Unicode code unit.
389  * - d A 32-bit integer. Also a 20 bit Unicode code point value.
390  * - l A 64-bit integer.
391  * - p A data pointer.
392  *
393  * Vectors
394  * -------
395  *
396  * If the 'v' is not specified, then one item of the specified type
397  * is passed in.
398  * If the 'v' (for "vector") is specified, then a vector of items of the
399  * specified type is passed in, via a pointer to the first item
400  * and an int32_t value for the length of the vector.
401  * Length==-1 means zero or NUL termination. Works for vectors of all types.
402  *
403  * Note: %vS is a vector of (UChar *) strings. The strings must
404  * be nul terminated as there is no way to provide a
405  * separate length parameter for each string. The length
406  * parameter (required for all vectors) is the number of
407  * strings, not the length of the strings.
408  *
409  * Examples
410  * --------
411  *
412  * These examples show the parameters that will be passed to an application's
413  * UTraceData() function for various formats.
414  *
415  * - the precise formatting is up to the application!
416  * - the examples use type casts for arguments only to _show_ the types of
417  * arguments without needing variable declarations in the examples;
418  * the type casts will not be necessary in actual code
419  *
420  * UTraceDataFunc(context, fnNumber, level,
421  * "There is a character %c in the string %s.", // Format String
422  * (char)c, (const char *)s); // varargs parameters
423  * -> There is a character 0x42 'B' in the string "Bravo".
424  *
425  * UTraceDataFunc(context, fnNumber, level,
426  * "Vector of bytes %vb vector of chars %vc",
427  * (const uint8_t *)bytes, (int32_t)bytesLength,
428  * (const char *)chars, (int32_t)charsLength);
429  * -> Vector of bytes
430  * 42 63 64 3f [4]
431  * vector of chars
432  * "Bcd?"[4]
433  *
434  * UTraceDataFunc(context, fnNumber, level,
435  * "An int32_t %d and a whole bunch of them %vd",
436  * (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);
437  * -> An int32_t 0xfffffffb and a whole bunch of them
438  * fffffffb 00000005 0000010a [3]
439  *
440  */
441 
442 
443 
463 U_CAPI int32_t U_EXPORT2
464 utrace_vformat(char *outBuf, int32_t capacity,
465  int32_t indent, const char *fmt, va_list args);
466 
484 U_CAPI int32_t U_EXPORT2
485 utrace_format(char *outBuf, int32_t capacity,
486  int32_t indent, const char *fmt, ...);
487 
488 
489 
490 /* Trace function numbers --------------------------------------------------- */
491 
501 U_CAPI const char * U_EXPORT2
502 utrace_functionName(int32_t fnNumber);
503 
505 
506 #endif
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:846
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:86
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:85
void UTraceData(const void *context, int32_t fnNumber, int32_t level, const char *fmt, va_list args)
Type signature for the trace function to be called from within an ICU function to display data or mes...
Definition: utrace.h:296
U_CAPI void utrace_setLevel(int32_t traceLevel)
Setter for the trace level.
U_CAPI int32_t utrace_format(char *outBuf, int32_t capacity, int32_t indent, const char *fmt,...)
Trace output Formatter.
U_CAPI const char * utrace_functionName(int32_t fnNumber)
Get the name of a function from its trace function number.
void UTraceEntry(const void *context, int32_t fnNumber)
Type signature for the trace function to be called when entering a function.
Definition: utrace.h:265
UTraceFunctionNumber
These are the ICU functions that will be traced when tracing is enabled.
Definition: utrace.h:65
@ UTRACE_UBRK_CREATE_BREAK_ENGINE
Indicates that an internal dictionary break engine was created.
Definition: utrace.h:228
@ UTRACE_FUNCTION_LIMIT
One more than the highest normal collation trace location.
Definition: utrace.h:75
@ UTRACE_UCOL_STRCOLLUTF8
Definition: utrace.h:105
@ UTRACE_COLLATION_LIMIT
One more than the highest normal collation trace location.
Definition: utrace.h:112
@ UTRACE_UBRK_CREATE_WORD
Indicates that a word instance of break iterator was created.
Definition: utrace.h:194
@ UTRACE_UDATA_BUNDLE
Indicates that a resource bundle was opened.
Definition: utrace.h:144
@ UTRACE_UBRK_START
The lowest break iterator location.
Definition: utrace.h:180
@ UTRACE_UBRK_CREATE_LINE
Indicates that a line instance of break iterator was created.
Definition: utrace.h:204
@ UTRACE_UBRK_CREATE_SENTENCE
Indicates that a sentence instance of break iterator was created.
Definition: utrace.h:211
@ UTRACE_UBRK_LIMIT
One more than the highest normal break iterator trace location.
Definition: utrace.h:235
@ UTRACE_UDATA_DATA_FILE
Indicates that a data file was opened, but not *.res files.
Definition: utrace.h:153
@ UTRACE_UDATA_START
The lowest resource/data location.
Definition: utrace.h:119
@ UTRACE_UBRK_CREATE_TITLE
Indicates that a title instance of break iterator was created.
Definition: utrace.h:218
@ UTRACE_UDATA_RESOURCE
Indicates that a value was read from a resource bundle.
Definition: utrace.h:136
@ UTRACE_UDATA_RES_FILE
Indicates that a *.res file was opened.
Definition: utrace.h:166
@ UTRACE_RES_DATA_LIMIT
One more than the highest normal resource/data trace location.
Definition: utrace.h:173
@ UTRACE_CONVERSION_LIMIT
One more than the highest normal collation trace location.
Definition: utrace.h:93
@ UTRACE_UBRK_CREATE_CHARACTER
Indicates that a character instance of break iterator was created.
Definition: utrace.h:187
U_CAPI int32_t utrace_vformat(char *outBuf, int32_t capacity, int32_t indent, const char *fmt, va_list args)
Trace output Formatter.
UTraceLevel
Trace severity levels.
Definition: utrace.h:46
@ UTRACE_WARNING
Trace errors and warnings.
Definition: utrace.h:52
@ UTRACE_ERROR
Trace error conditions only.
Definition: utrace.h:50
@ UTRACE_OPEN_CLOSE
Trace opens and closes of ICU services.
Definition: utrace.h:54
@ UTRACE_OFF
Disable all tracing.
Definition: utrace.h:48
@ UTRACE_INFO
Trace an intermediate number of ICU operations.
Definition: utrace.h:56
@ UTRACE_VERBOSE
Trace the maximum number of ICU operations.
Definition: utrace.h:58
U_CAPI void utrace_getFunctions(const void **context, UTraceEntry **e, UTraceExit **x, UTraceData **d)
Get the currently installed ICU tracing functions.
U_CAPI void utrace_setFunctions(const void *context, UTraceEntry *e, UTraceExit *x, UTraceData *d)
Set ICU Tracing functions.
void UTraceExit(const void *context, int32_t fnNumber, const char *fmt, va_list args)
Type signature for the trace function to be called when exiting from a function.
Definition: utrace.h:281
U_CAPI int32_t utrace_getLevel(void)
Getter for the trace level.
Basic definitions for ICU, for both C and C++ APIs.