utrace.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2003-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: utrace.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2003aug06
* created by: Markus W. Scherer
*
* Definitions for ICU tracing/logging.
*
*/
#ifndef __UTRACE_H__
#define __UTRACE_H__
#include <stdarg.h>
#include "unicode/utypes.h"
U_CDECL_BEGIN
typedef enum UTraceLevel {
UTRACE_OFF=-1,
UTRACE_ERROR=0,
UTRACE_WARNING=3,
UTRACE_OPEN_CLOSE=5,
UTRACE_INFO=7,
UTRACE_VERBOSE=9
} UTraceLevel;
typedef enum UTraceFunctionNumber {
UTRACE_FUNCTION_START=0,
UTRACE_U_INIT=UTRACE_FUNCTION_START,
UTRACE_U_CLEANUP,
#ifndef U_HIDE_DEPRECATED_API
UTRACE_FUNCTION_LIMIT,
#endif // U_HIDE_DEPRECATED_API
UTRACE_CONVERSION_START=0x1000,
UTRACE_UCNV_OPEN=UTRACE_CONVERSION_START,
UTRACE_UCNV_OPEN_PACKAGE,
UTRACE_UCNV_OPEN_ALGORITHMIC,
UTRACE_UCNV_CLONE,
UTRACE_UCNV_CLOSE,
UTRACE_UCNV_FLUSH_CACHE,
UTRACE_UCNV_LOAD,
UTRACE_UCNV_UNLOAD,
#ifndef U_HIDE_DEPRECATED_API
UTRACE_CONVERSION_LIMIT,
#endif // U_HIDE_DEPRECATED_API
UTRACE_COLLATION_START=0x2000,
UTRACE_UCOL_OPEN=UTRACE_COLLATION_START,
UTRACE_UCOL_CLOSE,
UTRACE_UCOL_STRCOLL,
UTRACE_UCOL_GET_SORTKEY,
UTRACE_UCOL_GETLOCALE,
UTRACE_UCOL_NEXTSORTKEYPART,
UTRACE_UCOL_STRCOLLITER,
UTRACE_UCOL_OPEN_FROM_SHORT_STRING,
UTRACE_UCOL_STRCOLLUTF8,
#ifndef U_HIDE_DEPRECATED_API
UTRACE_COLLATION_LIMIT,
#endif // U_HIDE_DEPRECATED_API
UTRACE_UDATA_START=0x3000,
UTRACE_UDATA_RESOURCE=UTRACE_UDATA_START,
UTRACE_UDATA_BUNDLE,
UTRACE_UDATA_DATA_FILE,
UTRACE_UDATA_RES_FILE,
#ifndef U_HIDE_INTERNAL_API
UTRACE_RES_DATA_LIMIT,
#endif // U_HIDE_INTERNAL_API
UTRACE_UBRK_START=0x4000,
UTRACE_UBRK_CREATE_CHARACTER = UTRACE_UBRK_START,
UTRACE_UBRK_CREATE_WORD,
UTRACE_UBRK_CREATE_LINE,
UTRACE_UBRK_CREATE_SENTENCE,
UTRACE_UBRK_CREATE_TITLE,
UTRACE_UBRK_CREATE_BREAK_ENGINE,
#ifndef U_HIDE_INTERNAL_API
UTRACE_UBRK_LIMIT,
#endif // U_HIDE_INTERNAL_API
} UTraceFunctionNumber;
U_CAPI void U_EXPORT2
utrace_setLevel(int32_t traceLevel);
U_CAPI int32_t U_EXPORT2
utrace_getLevel(void);
/* Trace function pointers types ----------------------------- */
typedef void U_CALLCONV
UTraceEntry(const void *context, int32_t fnNumber);
typedef void U_CALLCONV
UTraceExit(const void *context, int32_t fnNumber,
const char *fmt, va_list args);
typedef void U_CALLCONV
UTraceData(const void *context, int32_t fnNumber, int32_t level,
const char *fmt, va_list args);
U_CAPI void U_EXPORT2
utrace_setFunctions(const void *context,
UTraceEntry *e, UTraceExit *x, UTraceData *d);
U_CAPI void U_EXPORT2
utrace_getFunctions(const void **context,
UTraceEntry **e, UTraceExit **x, UTraceData **d);
/*
*
* ICU trace format string syntax
*
* Format Strings are passed to UTraceData functions, and define the
* number and types of the trace data being passed on each call.
*
* The UTraceData function, which is supplied by the application,
* not by ICU, can either forward the trace data (passed via
* varargs) and the format string back to ICU for formatting into
* a displayable string, or it can interpret the format itself,
* and do as it wishes with the trace data.
*
*
* Goals for the format string
* - basic data output
* - easy to use for trace programmer
* - sufficient provision for data types for trace output readability
* - well-defined types and binary portable APIs
*
* Non-goals
* - printf compatibility
* - fancy formatting
* - argument reordering and other internationalization features
*
* ICU trace format strings contain plain text with argument inserts,
* much like standard printf format strings.
* Each insert begins with a '%', then optionally contains a 'v',
* then exactly one type character.
* Two '%' in a row represent a '%' instead of an insert.
* The trace format strings need not have \n at the end.
*
*
* Types
* -----
*
* Type characters:
* - c A char character in the default codepage.
* - s A NUL-terminated char * string in the default codepage.
* - S A UChar * string. Requires two params, (ptr, length). Length=-1 for nul term.
* - b A byte (8-bit integer).
* - h A 16-bit integer. Also a 16 bit Unicode code unit.
* - d A 32-bit integer. Also a 20 bit Unicode code point value.
* - l A 64-bit integer.
* - p A data pointer.
*
* Vectors
* -------
*
* If the 'v' is not specified, then one item of the specified type
* is passed in.
* If the 'v' (for "vector") is specified, then a vector of items of the
* specified type is passed in, via a pointer to the first item
* and an int32_t value for the length of the vector.
* Length==-1 means zero or NUL termination. Works for vectors of all types.
*
* Note: %vS is a vector of (UChar *) strings. The strings must
* be nul terminated as there is no way to provide a
* separate length parameter for each string. The length
* parameter (required for all vectors) is the number of
* strings, not the length of the strings.
*
* Examples
* --------
*
* These examples show the parameters that will be passed to an application's
* UTraceData() function for various formats.
*
* - the precise formatting is up to the application!
* - the examples use type casts for arguments only to _show_ the types of
* arguments without needing variable declarations in the examples;
* the type casts will not be necessary in actual code
*
* UTraceDataFunc(context, fnNumber, level,
* "There is a character %c in the string %s.", // Format String
* (char)c, (const char *)s); // varargs parameters
* -> There is a character 0x42 'B' in the string "Bravo".
*
* UTraceDataFunc(context, fnNumber, level,
* "Vector of bytes %vb vector of chars %vc",
* (const uint8_t *)bytes, (int32_t)bytesLength,
* (const char *)chars, (int32_t)charsLength);
* -> Vector of bytes
* 42 63 64 3f [4]
* vector of chars
* "Bcd?"[4]
*
* UTraceDataFunc(context, fnNumber, level,
* "An int32_t %d and a whole bunch of them %vd",
* (int32_t)-5, (const int32_t *)ints, (int32_t)intsLength);
* -> An int32_t 0xfffffffb and a whole bunch of them
* fffffffb 00000005 0000010a [3]
*
*/
U_CAPI int32_t U_EXPORT2
utrace_vformat(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, va_list args);
U_CAPI int32_t U_EXPORT2
utrace_format(char *outBuf, int32_t capacity,
int32_t indent, const char *fmt, ...);
/* Trace function numbers --------------------------------------------------- */
U_CAPI const char * U_EXPORT2
utrace_functionName(int32_t fnNumber);
U_CDECL_END
#endif
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:866
U_CDECL_END
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:86
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
U_CDECL_BEGIN
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:85
UTraceData
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
utrace_setLevel
U_CAPI void utrace_setLevel(int32_t traceLevel)
Setter for the trace level.
utrace_format
U_CAPI int32_t utrace_format(char *outBuf, int32_t capacity, int32_t indent, const char *fmt,...)
Trace output Formatter.
utrace_functionName
U_CAPI const char * utrace_functionName(int32_t fnNumber)
Get the name of a function from its trace function number.
UTraceEntry
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
UTraceFunctionNumber
These are the ICU functions that will be traced when tracing is enabled.
Definition: utrace.h:65
UTRACE_UBRK_CREATE_BREAK_ENGINE
@ UTRACE_UBRK_CREATE_BREAK_ENGINE
Indicates that an internal dictionary break engine was created.
Definition: utrace.h:228
UTRACE_FUNCTION_LIMIT
@ UTRACE_FUNCTION_LIMIT
One more than the highest normal collation trace location.
Definition: utrace.h:75
UTRACE_UCOL_STRCOLLUTF8
@ UTRACE_UCOL_STRCOLLUTF8
Definition: utrace.h:105
UTRACE_COLLATION_LIMIT
@ UTRACE_COLLATION_LIMIT
One more than the highest normal collation trace location.
Definition: utrace.h:112
UTRACE_UBRK_CREATE_WORD
@ UTRACE_UBRK_CREATE_WORD
Indicates that a word instance of break iterator was created.
Definition: utrace.h:194
UTRACE_UDATA_BUNDLE
@ UTRACE_UDATA_BUNDLE
Indicates that a resource bundle was opened.
Definition: utrace.h:144
UTRACE_UBRK_START
@ UTRACE_UBRK_START
The lowest break iterator location.
Definition: utrace.h:180
UTRACE_UBRK_CREATE_LINE
@ UTRACE_UBRK_CREATE_LINE
Indicates that a line instance of break iterator was created.
Definition: utrace.h:204
UTRACE_UBRK_CREATE_SENTENCE
@ UTRACE_UBRK_CREATE_SENTENCE
Indicates that a sentence instance of break iterator was created.
Definition: utrace.h:211
UTRACE_UBRK_LIMIT
@ UTRACE_UBRK_LIMIT
One more than the highest normal break iterator trace location.
Definition: utrace.h:235
UTRACE_UDATA_DATA_FILE
@ UTRACE_UDATA_DATA_FILE
Indicates that a data file was opened, but not *.res files.
Definition: utrace.h:153
UTRACE_UDATA_START
@ UTRACE_UDATA_START
The lowest resource/data location.
Definition: utrace.h:119
UTRACE_UBRK_CREATE_TITLE
@ UTRACE_UBRK_CREATE_TITLE
Indicates that a title instance of break iterator was created.
Definition: utrace.h:218
UTRACE_UDATA_RESOURCE
@ UTRACE_UDATA_RESOURCE
Indicates that a value was read from a resource bundle.
Definition: utrace.h:136
UTRACE_UDATA_RES_FILE
@ UTRACE_UDATA_RES_FILE
Indicates that a *.res file was opened.
Definition: utrace.h:166
UTRACE_RES_DATA_LIMIT
@ UTRACE_RES_DATA_LIMIT
One more than the highest normal resource/data trace location.
Definition: utrace.h:173
UTRACE_CONVERSION_LIMIT
@ UTRACE_CONVERSION_LIMIT
One more than the highest normal collation trace location.
Definition: utrace.h:93
UTRACE_UBRK_CREATE_CHARACTER
@ UTRACE_UBRK_CREATE_CHARACTER
Indicates that a character instance of break iterator was created.
Definition: utrace.h:187
utrace_vformat
U_CAPI int32_t utrace_vformat(char *outBuf, int32_t capacity, int32_t indent, const char *fmt, va_list args)
Trace output Formatter.
UTraceLevel
UTraceLevel
Trace severity levels.
Definition: utrace.h:46
UTRACE_WARNING
@ UTRACE_WARNING
Trace errors and warnings.
Definition: utrace.h:52
UTRACE_ERROR
@ UTRACE_ERROR
Trace error conditions only.
Definition: utrace.h:50
UTRACE_OPEN_CLOSE
@ UTRACE_OPEN_CLOSE
Trace opens and closes of ICU services.
Definition: utrace.h:54
UTRACE_OFF
@ UTRACE_OFF
Disable all tracing.
Definition: utrace.h:48
UTRACE_INFO
@ UTRACE_INFO
Trace an intermediate number of ICU operations.
Definition: utrace.h:56
UTRACE_VERBOSE
@ UTRACE_VERBOSE
Trace the maximum number of ICU operations.
Definition: utrace.h:58
utrace_getFunctions
U_CAPI void utrace_getFunctions(const void **context, UTraceEntry **e, UTraceExit **x, UTraceData **d)
Get the currently installed ICU tracing functions.
utrace_setFunctions
U_CAPI void utrace_setFunctions(const void *context, UTraceEntry *e, UTraceExit *x, UTraceData *d)
Set ICU Tracing functions.
UTraceExit
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
utrace_getLevel
U_CAPI int32_t utrace_getLevel(void)
Getter for the trace level.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.