dxFeed Graal Native SDK 3.12.0
Loading...
Searching...
No Matches
Logging (v4)

The v4 functions and type names of the group Logging. Every function returns DXFG_EXECUTE_SUCCESSFULLY or DXFG_EXECUTE_FAIL and writes its result to a DXFG_OUT parameter, see The v4 functions. More...

Typedefs

typedef dxfg_logging_level_t dxfg_v4_logging_level_t
 The logging levels that can be used to control the logging output.
typedef dxfg_logging_listener_t dxfg_v4_logging_listener_t
 A handle of a Java InterceptableLoggingListener object, a wrapper of a listener that allows to intercept the logged messages; release it with dxfg_JavaObjectHandler_release().
typedef dxfg_logging_listener_function_t dxfg_v4_logging_listener_function_t
 The function of a dxfg_logging_listener_t: called for every message that is logged while the listener is installed and the level of the message is not below the logging level (see dxfg_logging_set_log_level()).

Functions

int32_t dxfg_v4_logging_listener_new (graal_isolatethread_t *thread, dxfg_v4_logging_listener_function_t user_func, void *user_data, DXFG_OUT dxfg_v4_logging_listener_t **listener)
 Creates a new logging listener.
int32_t dxfg_v4_logging_set_listener (graal_isolatethread_t *thread, dxfg_v4_logging_listener_t *listener)
 Installs the logging listener.
int32_t dxfg_v4_logging_set_log_level (graal_isolatethread_t *thread, dxfg_v4_logging_level_t level)
 Sets the logging level for the listener or the console or the log file.
int32_t dxfg_v4_logging_set_err_level (graal_isolatethread_t *thread, dxfg_v4_logging_level_t level)
 Sets the logging level for the err file.

Detailed Description

The v4 functions and type names of the group Logging. Every function returns DXFG_EXECUTE_SUCCESSFULLY or DXFG_EXECUTE_FAIL and writes its result to a DXFG_OUT parameter, see The v4 functions.

Typedef Documentation

◆ dxfg_v4_logging_level_t

The logging levels that can be used to control the logging output.

The values correspond to the levels of java.util.logging.Level that the logging system uses.

Java: java.util.logging.Level.

◆ dxfg_v4_logging_listener_function_t

The function of a dxfg_logging_listener_t: called for every message that is logged while the listener is installed and the level of the message is not below the logging level (see dxfg_logging_set_log_level()).

The function is called synchronously by the Java thread that logs the message, which may be any thread of the isolate (including the threads of the endpoints), not the thread that installed the listener. The calls are serialized by a lock of the logging system: the function is never called concurrently, and while it runs the other threads that log wait. So it should return quickly and should not block.

The strings and the exception are allocated by the SDK for the call and released by the SDK after the function returns: copy what is needed, do not keep the pointers and do not release them. A string or the exception is NULL when the corresponding value is absent.

Java: InterceptableLoggingListener.onLog(Level, long, String, long, String, String, Throwable, String).

Parameters
[in]threadThe current GraalVM Isolate's thread.
[in]levelThe level of the message.
[in]timestampThe time of the message in milliseconds since the Unix epoch (UTC).
[in]thread_nameThe name of the Java thread that logged the message, a NUL-terminated UTF-8 string.
[in]thread_idThe identifier of the Java thread that logged the message.
[in]logger_nameThe name of the logger, a NUL-terminated UTF-8 string (NULL if the logger has no name).
[in]messageThe text of the message without the time, the level and other parts of the layout, a NUL-terminated UTF-8 string.
[in]exceptionThe exception that is logged with the message, or NULL if there is none. See dxfg_exception_t.
[in]formatted_messageThe whole line that the logging system would write: the message with the time, the level, the thread and the exception formatted with the layout of the logging system, a NUL-terminated UTF-8 string.
[in]user_dataThe pointer that was passed to dxfg_logging_listener_new(); the SDK does not use it.

◆ dxfg_v4_logging_listener_t

A handle of a Java InterceptableLoggingListener object, a wrapper of a listener that allows to intercept the logged messages; release it with dxfg_JavaObjectHandler_release().

Create it with dxfg_logging_listener_new() and install it with dxfg_logging_set_listener(). The last handle of the listener that is released deactivates the listener: its function is not called anymore.

Function Documentation

◆ dxfg_v4_logging_listener_new()

int32_t dxfg_v4_logging_listener_new ( graal_isolatethread_t * thread,
dxfg_v4_logging_listener_function_t user_func,
void * user_data,
DXFG_OUT dxfg_v4_logging_listener_t ** listener )

Creates a new logging listener.

The listener does nothing until it is installed with dxfg_v4_logging_set_listener(). The function is called as described at dxfg_v4_logging_listener_function_t.

Releasing the last handle of the listener with dxfg_v4_JavaObjectHandler_release() (or dxfg_v4_NativeListener_deactivate()) stops the calls of the function: after the release returns the function is not running and is not called anymore, so the user data can be freed. An installed listener cannot be replaced or removed (see dxfg_v4_logging_set_listener()), it can only be deactivated this way.

Java: InterceptableLoggingListener.onLog(Level, long, String, long, String, String, Throwable, String).

Parameters
[in]threadThe current GraalVM Isolate's thread.
[in]user_funcThe listener callback.
[in]user_dataThe user data that will be passed to the callback; the SDK does not use it. It must stay valid until the listener is deactivated.
[out]listenerThe pointer to the variable that receives the new listener (release its handle with dxfg_v4_JavaObjectHandler_release()). It is written only on success. A NULL pointer is an error.
Returns
DXFG_EXECUTE_SUCCESSFULLY (0) on successful function execution or DXFG_EXECUTE_FAIL (-1) on error. Use dxfg_v4_get_and_clear_thread_exception() to determine if an exception was thrown.

◆ dxfg_v4_logging_set_err_level()

int32_t dxfg_v4_logging_set_err_level ( graal_isolatethread_t * thread,
dxfg_v4_logging_level_t level )

Sets the logging level for the err file.

The level is set for the second handler of the logging system: the file of the errors (err.file). If there is no such handler (e.g. a listener is installed or err.file is not set), the function does nothing and returns DXFG_EXECUTE_SUCCESSFULLY. The default level of the err file is taken from the system property err.level (warnings and errors by default).

Java: InterceptableLogging.setErrLevel(Level).

Parameters
[in]threadThe current GraalVM Isolate's thread.
[in]levelThe new logging level.
Returns
DXFG_EXECUTE_SUCCESSFULLY (0) on successful function execution or DXFG_EXECUTE_FAIL (-1) on error. Use dxfg_v4_get_and_clear_thread_exception() to determine if an exception was thrown.

◆ dxfg_v4_logging_set_listener()

int32_t dxfg_v4_logging_set_listener ( graal_isolatethread_t * thread,
dxfg_v4_logging_listener_t * listener )

Installs the logging listener.

It toggles the logging: the existing handlers of the logging system are removed, so the messages are not logged to the console and to files anymore, and the messages are given to the listener. The level of the messages that reach the listener is taken from the system property log.level (all messages by default) and can be changed with dxfg_v4_logging_set_log_level().

Only the first installed listener works: if a listener is already installed, the function does nothing. A NULL listener does nothing as well. In both cases the function returns DXFG_EXECUTE_SUCCESSFULLY. The installed listener cannot be removed; release its handle (see dxfg_v4_logging_listener_new()) to stop its calls.

Java: InterceptableLogging.setListener(InterceptableLoggingListener).

Parameters
[in]threadThe current GraalVM Isolate's thread.
[in]listenerThe logging listener. The caller keeps its handle.
Returns
DXFG_EXECUTE_SUCCESSFULLY (0) on successful function execution or DXFG_EXECUTE_FAIL (-1) on error. Use dxfg_v4_get_and_clear_thread_exception() to determine if an exception was thrown.

◆ dxfg_v4_logging_set_log_level()

int32_t dxfg_v4_logging_set_log_level ( graal_isolatethread_t * thread,
dxfg_v4_logging_level_t level )

Sets the logging level for the listener or the console or the log file.

The level is set for the first handler of the logging system: the handler of the listener if one is installed (see dxfg_v4_logging_set_listener()), otherwise the console or the log file (log.file). If there is no such handler, the function does nothing and returns DXFG_EXECUTE_SUCCESSFULLY.

Java: InterceptableLogging.setLogLevel(Level).

Parameters
[in]threadThe current GraalVM Isolate's thread.
[in]levelThe new logging level.
Returns
DXFG_EXECUTE_SUCCESSFULLY (0) on successful function execution or DXFG_EXECUTE_FAIL (-1) on error. Use dxfg_v4_get_and_clear_thread_exception() to determine if an exception was thrown.