High Performance OPC UA Server SDK
1.5.0.296
|
Writing trace messages. More...
Macros | |
#define | TRACE_LEVEL_DEBUG 1 |
Identifier for debug trace level: also logs internal variables/states, only useful for developers. | |
#define | TRACE_LEVEL_DATA 2 |
Identifier for data trace level: logs process data (e.g. More... | |
#define | TRACE_LEVEL_INFO 4 |
Identifier for info trace level: informational (e.g. More... | |
#define | TRACE_LEVEL_FUNC_ENTER 8 |
Identifier for function enter trace level. | |
#define | TRACE_LEVEL_FUNC_LEAVE 16 |
Identifier for function leave trace level. | |
#define | TRACE_LEVEL_FUNC 24 |
Identifier for function trace level. | |
#define | TRACE_LEVEL_NOTICE 32 |
Identifier for notice trace level: normal but significant condition, e.g. More... | |
#define | TRACE_LEVEL_WARNING 64 |
Identifier for warning trace level. More... | |
#define | TRACE_LEVEL_ERROR 128 |
Identifier for error trace level: error conditions, e.g. More... | |
#define | TRACE_LEVEL_INSANE 256 |
Identifier for insane trace level, produces a lot of output! This is used for cyclic events. | |
#define | TRACE_LEVEL_ALL 511 |
Combination of all trace levels. | |
#define | TRACE_FAC_PLATFORM 1 |
Identifier for platform facility. | |
#define | TRACE_FAC_NETWORK 2 |
Identifier for network facility. | |
#define | TRACE_FAC_CRYPTO 4 |
Identifier for crypto facility. | |
#define | TRACE_FAC_IPC 8 |
Identifier for IPC facility. | |
#define | TRACE_FAC_BASE 16 |
Identifier for base facility. | |
#define | TRACE_FAC_MEMORY 32 |
Identifier for memory facility. | |
#define | TRACE_FAC_UATCP 64 |
Identifier for UATCP facility. | |
#define | TRACE_FAC_ENCODER 128 |
Identifier for encoder facility. | |
#define | TRACE_FAC_SESSION 256 |
Identifier for session facility. | |
#define | TRACE_FAC_PROVIDER 512 |
Identifier for provider facility. | |
#define | TRACE_FAC_APPLICATION 1024 |
Identifier for application facility. | |
#define | TRACE_FAC_ADDRSPACE 2048 |
Identifier for address space facility. | |
#define | TRACE_FAC_TIMER 4096 |
Identifier for timer facility. | |
#define | TRACE_FAC_PKI 8192 |
Identifier for timer facility. | |
#define | TRACE_FAC_SUBSCRIPTION 16384 |
Identifier for subscription facility. | |
#define | TRACE_FAC_CLIENT 32768 |
Identifier for client facility. | |
#define | TRACE_FAC_USERAPPLICATION 65536 |
Reserved for the user application. More... | |
#define | TRACE_FAC_GDS 131072 |
Identifier for GDS facility. | |
#define | TRACE_FAC_FILEFORMAT (1 << 17) |
Identifier for file format facility. | |
#define | TRACE_FAC_FILETRANSFER (1 << 18) |
Identifier for filetransfer facility. | |
#define | TRACE_FAC_PUBSUB (1 << 19) |
Identifier for pubsub facility. | |
#define | TRACE_FAC_ALL ((1 << 20) - 1) |
Combination of all facilities. | |
#define | TRACE_SECMASK_SHOW_USERNAME 1 |
#define | TRACE_SECMASK_SHOW_PASSWORD 2 |
#define | TRACE_SECMASK_SHOW_IPADDRESS 4 |
#define | TRACE_SECMASK_SHOW_ALL 7 |
Enables all sensitive information. | |
#define | TRACE_DEBUG(facility, format, ...) trace_log(TRACE_LEVEL_DEBUG, facility, format, ##__VA_ARGS__) |
Convenience define for tracing with debug level. | |
#define | TRACE_DATA(facility, format, ...) trace_log(TRACE_LEVEL_DATA, facility, format, ##__VA_ARGS__) |
Convenience define for tracing with data level. | |
#define | TRACE_INFO(facility, format, ...) trace_log(TRACE_LEVEL_INFO, facility, format, ##__VA_ARGS__) |
Convenience define for tracing with info level. | |
#define | TRACE_NOTICE(facility, format, ...) trace_log(TRACE_LEVEL_NOTICE, facility, format, ##__VA_ARGS__) |
Convenience define for tracing with notic level. | |
#define | TRACE_WARNING(facility, format, ...) trace_log(TRACE_LEVEL_WARNING, facility, format, ##__VA_ARGS__) |
Convenience define for tracing with warning level. | |
#define | TRACE_ERROR(facility, format, ...) trace_log(TRACE_LEVEL_ERROR, facility, format, ##__VA_ARGS__) |
Convenience define for tracing with error level. | |
#define | TRACE_INSANE(facility, format, ...) |
Convenience define for tracing with insane level. | |
#define | TRACE_ENTER(facility, funcname) trace_log(TRACE_LEVEL_FUNC_ENTER, facility, "> %s\n", funcname); trace_indent() |
Trace with function enter level, adds an indent. | |
#define | TRACE_RETURN(facility, funcname) trace_unindent(); trace_log(TRACE_LEVEL_FUNC_LEAVE, facility, "< %s\n", funcname) |
Trace with function leave level, removes an indent. | |
#define | TRACE_RETURNERR(facility, funcname, result) trace_unindent(); trace_log(TRACE_LEVEL_FUNC_LEAVE, facility, "< %s - return 0x%08X\n", funcname, result) |
Trace with function leave level, removes an indent and prints errorcode. | |
#define | TRACE_ENTERD(facility, funcname) trace_log(TRACE_LEVEL_INSANE, facility, "> %s\n", funcname); trace_indent() |
Trace function enter with insane level, adds an indent. | |
#define | TRACE_RETURND(facility, funcname) trace_unindent(); trace_log(TRACE_LEVEL_INSANE, facility, "< %s\n", funcname) |
Trace function leave with insane level, removes an indent. | |
#define | TRACE_RETURNERRD(facility, funcname, result) trace_unindent(); trace_log(TRACE_LEVEL_INSANE, facility, "< %s - return 0x%08X\n", funcname, result) |
Trace function leave with insane level, removes an indent and prints errorcode. | |
#define | TRACE_HEXDUMP(facility, data, len) trace_hexdump(TRACE_LEVEL_DATA, facility, data, len) |
#define | TRACE_USERNAME(x) trace_username(x) |
#define | TRACE_PASSWORD(x) trace_password(x) |
#define | TRACE_IPv4(x) trace_ipv4(x) |
#define | TRACE_IPv6(x) trace_ipv6(x) |
Functions | |
int | trace_openlog (int level_mask, int facility_mask) |
Initialize the trace backend. More... | |
void | trace_log (int level, int facility, const char *format,...) TRACE_FORMAT_ARGUMENT(3 |
Write to trace. More... | |
void void | trace_hexdump (int level, int facility, const unsigned char *data, size_t count) |
Writes the hexdump of the given data to trace output. More... | |
void | trace_closelog (void) |
Close the trace backend. | |
int | trace_change_trace_level (int level_mask, int facility_mask) |
Change the trace level and facility. More... | |
int | trace_change_security_level (int security_mask) |
Changes the security level of the trace output. More... | |
int | trace_get_security_level (void) |
int | trace_enabled (int level) |
Test if a certain trace level is enabled. More... | |
void | trace_indent (void) |
Add an indent to all further traces messages. | |
void | trace_unindent (void) |
Remove an indent from all further trace messages. | |
const char * | trace_username (const char *username) |
Returns the username as-is if TRACE_SECMASK_SHOW_USERNAME is set, otherwise the string "<hidden>". More... | |
const char * | trace_password (const char *password) |
Returns the password as-is if TRACE_SECMASK_SHOW_PASSWORD is set, otherwise the string "XXX". More... | |
const char * | trace_ipv4 (const unsigned char ipv4[4]) |
Returns the string representation of the given IPv4 address if TRACE_SECMASK_SHOW_IPADDRESS is set, otherwise an anonymised version of it. More... | |
const char * | trace_ipv6 (const unsigned char ipv6[16]) |
Returns the string representation of the given IPv6 address if TRACE_SECMASK_SHOW_IPADDRESS is set, otherwise an anonymised version of it. More... | |
void | trace_print_flags (const char *appname) |
Writing trace messages.
The SDK has multiple trace backends implemented, which can be selected using the cmake switch TRACE_BACKEND. Each of them writes the trace to a different location. To disable the trace completely the cmake switch TRACE_ENABLED must be disabled.
Each trace message is written with a level to indicate the severity of the message and a facility to assign the message to a component. Depending of the trace backend the trace messages may be prefixed with timestamps, the output can be colored, etc. See Trace Module for more general information about the different trace backends.
#define TRACE_FAC_USERAPPLICATION 65536 |
Reserved for the user application.
Not used in the SDK.
#define TRACE_LEVEL_DATA 2 |
Identifier for data trace level: logs process data (e.g.
read/written values)
#define TRACE_LEVEL_ERROR 128 |
Identifier for error trace level: error conditions, e.g.
file access denied, out of memory, etc.
#define TRACE_LEVEL_INFO 4 |
Identifier for info trace level: informational (e.g.
app started, shutdown, connect, disconnect, subscription created, ...)
#define TRACE_LEVEL_NOTICE 32 |
Identifier for notice trace level: normal but significant condition, e.g.
authentication denied
#define TRACE_LEVEL_WARNING 64 |
Identifier for warning trace level.
e.g. the certificate may expire soon, only 1MB of memory left, etc.
int trace_change_security_level | ( | int | security_mask | ) |
Changes the security level of the trace output.
By default no sensitive information like username, passwords or IP addresses are written to the trace. The prevents accidental leakage of sensitive information if trace are sent to other people, e.g. to get support.
However you can enable tracing of sensitive information by calling this function and set the security_mask. Note that this only has the desired effect if all trace lines use the special trace macros which honer this security mask.
security_mask | Bitwise ORed TRACE_SECMASK_* values. |
int trace_change_trace_level | ( | int | level_mask, |
int | facility_mask | ||
) |
Change the trace level and facility.
level_mask | New trace level mask. |
facility_mask | New trace facility mask. |
int trace_enabled | ( | int | level | ) |
Test if a certain trace level is enabled.
level | Trace level to test. |
Test if a certain trace level is enabled.
If the trace level is disabled this function returns zero.
void void trace_hexdump | ( | int | level, |
int | facility, | ||
const unsigned char * | data, | ||
size_t | count | ||
) |
Writes the hexdump of the given data to trace output.
level | Level to trace to. |
facility | Facility to trace to. |
data | Pointer to data which should be dumped. |
count | Length of data in bytes. |
const char* trace_ipv4 | ( | const unsigned char | ipv4[4] | ) |
Returns the string representation of the given IPv4 address if TRACE_SECMASK_SHOW_IPADDRESS is set, otherwise an anonymised version of it.
You should used the macro TRACE_IPv6 instead of calling this function directly.
Example usage:
const char* trace_ipv6 | ( | const unsigned char | ipv6[16] | ) |
Returns the string representation of the given IPv6 address if TRACE_SECMASK_SHOW_IPADDRESS is set, otherwise an anonymised version of it.
You should used the macro TRACE_IPv6 instead of calling this function directly.
Example usage:
void trace_log | ( | int | level, |
int | facility, | ||
const char * | format, | ||
... | |||
) |
Write to trace.
level | Level to trace to. |
facility | Facility to trace to. |
format | Format specifier like for printf(). |
int trace_openlog | ( | int | level_mask, |
int | facility_mask | ||
) |
Initialize the trace backend.
level_mask | Bitwise OR of trace levels to trace. |
facility_mask | Bitwise OR of trace facilities to trace. |
const char* trace_password | ( | const char * | password | ) |
Returns the password
as-is if TRACE_SECMASK_SHOW_PASSWORD is set, otherwise the string "XXX".
You should used the macro TRACE_PASSWORD instead of calling this function directly.
Example usage:
const char* trace_username | ( | const char * | username | ) |
Returns the username
as-is if TRACE_SECMASK_SHOW_USERNAME is set, otherwise the string "<hidden>".
You should used the macro TRACE_USERNAME instead of calling this function directly.
Example usage: