Skip to content

Group cuvis_log

Modules > cuvis_log

More...

Public Types

Type Name
enum cuvis_loglevel_t
The available log levels.
typedef void(SDK_CCALL * log_callback
typedef void(SDK_CCALL * log_callback_localized

Public Functions

Type Name
SDK_CAPI CUVIS_STATUS SDK_CCALL cuvis_register_log_callback (log_callback i_callback, CUVIS_INT i_min_level)
SDK_CAPI CUVIS_STATUS SDK_CCALL cuvis_register_log_callback_localized (log_callback_localized i_callback_localized, CUVIS_INT i_min_level, CUVIS_CHAR const * i_locale_id)
SDK_CAPI CUVIS_STATUS SDK_CCALL cuvis_reset_log_callback ()
SDK_CAPI CUVIS_STATUS SDK_CCALL cuvis_reset_log_callback_localized ()
SDK_CAPI CUVIS_STATUS SDK_CCALL cuvis_set_log_level (CUVIS_INT level)

Detailed Description

There are several ways to configure the logging behaviour in the Cuvis SDK.

Logfile Configuration Behaviour

The SDK provides the possibility to write the log to a logfile. For this a "log.cfg" file has to be created at a certain position.

When a local ".cuvis" directory exists with an empty "log.cfg" file, the cuvis sdk will create a debug log in that directory. The log file name is the process name followed by log, e.g. "example.exe.log", if the process is named "example.log"

If a local ".cuvis" directory is not found, the system-wide configuration of the logging is used (activated by default from the installation of cuvis): The configuration can be found under PROGRAMDATA%/cuvis/log.cfg (usually "C:/Program Data/cuvis/log.cfg") for Windows or /etc/cuvis/log.cfg for linux. The log output can be found under PROGRAMDATA%/cuvis for Windows and /var/log/cuvis for linux.

Loglevel at Runtime

Secondly there is the option to adapt the logging behaviour the the standard output stream via cuvis_set_log_level.

Registration of Log Callbacks

As a third option there is the possibility to register a function as a callback that will be called every time a new log message is recevied with the requested log level. See cuvis_register_log_callback and cuvis_register_log_callback_localized for more information.

Public Types Documentation

enum cuvis_loglevel_t

The available log levels.

enum cuvis_loglevel_t {
    loglevel_fatal = 0,
    loglevel_error = 1,
    loglevel_warning = 2,
    loglevel_info = 3,
    loglevel_debug = 4
};


typedef log_callback

typedef void(SDK_CCALL * log_callback) (const char *msg, CUVIS_INT level);

typedef log_callback_localized

typedef void(SDK_CCALL * log_callback_localized) (const CUVIS_WCHAR *msg, CUVIS_INT level);

Public Functions Documentation

function cuvis_register_log_callback

SDK_CAPI  CUVIS_STATUS  SDK_CCALL cuvis_register_log_callback (
    log_callback i_callback,
    CUVIS_INT i_min_level
) 

Register an additional logger. Only one classic callback will be set, multiple calls will overwrite the previous callback. The callback's message argument pointer is only valid during the runtime of the callback. The "classic" logger will output original messages, instead of it's respective translations. For localized (translated) messages,

See also: cuvis_reset_log_callback_localized.

Note:

The classical logger and localized logger can be used simultaneously.

Parameters:

  • i_callback the function callback
  • i_min_level the minimum level of the callback

function cuvis_register_log_callback_localized

SDK_CAPI  CUVIS_STATUS  SDK_CCALL cuvis_register_log_callback_localized (
    log_callback_localized i_callback_localized,
    CUVIS_INT i_min_level,
    CUVIS_CHAR const * i_locale_id
) 

Register an additional logger with localized language. Only one callback will be set, multiple calls will overwrite the previous callback. The callback's message argument pointer is only valid during the runtime of the callback.

Note:

The classical logger and localized logger can be used simultaneously.

Parameters:

  • i_callback_localized the function callback
  • i_min_level the minimum level of the callback
  • i_locale_id set the locale id, e.g. "de-DE.UTF8" for german. See the "locale" directory for available translations.

function cuvis_reset_log_callback

SDK_CAPI  CUVIS_STATUS  SDK_CCALL cuvis_reset_log_callback () 

Unregister the additional logger. This will not clear the localized logger


function cuvis_reset_log_callback_localized

SDK_CAPI  CUVIS_STATUS  SDK_CCALL cuvis_reset_log_callback_localized () 

Unregister the additional localized logger. This will not clear the classic logger


function cuvis_set_log_level

SDK_CAPI  CUVIS_STATUS  SDK_CCALL cuvis_set_log_level (
    CUVIS_INT level
) 

Set the internal log level. Log output will be redirected to cout

If this function is not called, a failback logger is used, with loglevel "warning" The failback logger is de-activated, when this function is called or when a callback is registered for the log messages. However, when this function is called, messages are logged to console, even when a callaback is registered. debug = 4, info = 3, warning = 2, error = 1, fatal = 0

Parameters:

  • level the log level to be set