Learn how to evaluate and integrate the VNC SDK

We're here if you need help.

Logger.h

Handle log messages from the SDK. (more...)

Data structures

Modifier and Type Name and Description
struct

vnc_Logger_Callback

Callback which handles log messages.

Enums

Modifier and Type Name and Description
enum

vnc_Logger_Level

Enumeration of log levels.

Functions

Modifier and Type Name and Description
function void

vnc_Logger_setLevel(vnc_Logger_Level level)

Sets the current log level.

function vnc_status_t

vnc_Logger_createCustomLogger(const vnc_Logger_Callback *callback, void *userData)

Creates a logger implementation that calls the given callback whenever a log message is written.

function vnc_status_t

vnc_Logger_createFileLogger(const char *path)

Creates a logger that writes data to the specified log file.

function void

vnc_Logger_createAndroidLogger()

Creates a logger implementation that writes data to the Android log.

function void

vnc_Logger_createStderrLogger()

Creates a logger implementation that writes data to stderr.

function void

vnc_Logger_createBrowserLogger()

Creates a logger implementation that writes data to the web browser’s debugging console.

function void

vnc_Logger_destroyLogger()

Destroys any previously created logger.

Detailed description

Handle log messages from the SDK.

The SDK will log messages using a logger set by these functions. Initially, the SDK has no logger. If no logger has been created, or an existing logger has been destroyed, no logging is done. Only one logger can be in use at a time. Any existing logger is destroyed when a new one is created.

Typically, a logger is created before vnc_init() is called, so that information can be logged while the SDK is initializing.

A logger only logs messages whose level is equal to or lower than the logger’s current level. The current level for the logger is set using vnc_Logger_setLevel().

Functions are provided to create various types of standard loggers. For most platforms, vnc_Logger_createStderrLogger() is useful for debugging your application, and vnc_Logger_createFileLogger() is suitable for use in production applications. In order to use a custom or OS-provided logging framework, you can implement a custom logger for handling log messages yourself.

Enums

enum vnc_Logger_Level

Enumeration of log levels.

These can be used to filter out log messages that are not needed. Each level includes lower levels as well.

Values:

vnc_Logger_Error = 0

Information that the program is likely to stop functioning correctly.

vnc_Logger_Basic = 1

Useful information on the functioning of the system.

This is the default log level.

vnc_Logger_Full = 2

Comprehensive logging of all SDK operations (may degrade performance, and the log file will also contain secure information such as keystrokes)

vnc_Logger_Debug = 3

Logging of SDK operations, and for debug purposes, logging of internal information specific to RealVNC’s implementation.

Functions

void vnc_Logger_setLevel(vnc_Logger_Level level)

Sets the current log level.

Messages will only be logged whose level is less than or equal to this. See the vnc_Logger_Level enumeration for possible log levels.

Parameters
  • level -

    The new level.

vnc_status_t vnc_Logger_createCustomLogger(const vnc_Logger_Callback *callback, void *userData)

Creates a logger implementation that calls the given callback whenever a log message is written.

This destroys any previously-created logger.

Return
vnc_success or vnc_failure, in which case call vnc_getLastError() to get the error code.
Parameters
  • callback -

    The new callback.

Return Value

vnc_status_t vnc_Logger_createFileLogger(const char *path)

Creates a logger that writes data to the specified log file.

This function is not available on the HTML5 platform. This destroys any previously-created logger.

Return
vnc_success or vnc_failure, in which case call vnc_getLastError() to get the error code.
Parameters
  • path -

    A full path to and name for the log file.

Return Value
  • InvalidArgument -

    path is invalid

  • FileError -

    The log file could not be opened or created

void vnc_Logger_createAndroidLogger(void)

Creates a logger implementation that writes data to the Android log.

This function is only available on Android. This destroys any previously-created logger.

void vnc_Logger_createStderrLogger(void)

Creates a logger implementation that writes data to stderr.

This function is not available on the HTML5 platform. This destroys any previously-created logger.

void vnc_Logger_createBrowserLogger(void)

Creates a logger implementation that writes data to the web browser’s debugging console.

This function is only available on the HTML5 platform. This destroys any previously-created logger.

void vnc_Logger_destroyLogger(void)

Destroys any previously created logger.

Without a logger, all log data is silently discarded.

struct vnc_Logger_Callback
#include <Logger.h>

Callback which handles log messages.

Public Members

void(* vnc_Logger_Callback::logMessage) (void *userData, vnc_Logger_Level level, const char *message)

Notification of log messages generated by the SDK.

This callback is required for a custom logger. The callback is only notified for messages with level less than or equal to the current log level.

Parameters
  • level -

    The lowest level at which the message would be generated.

  • message -

    A human-readable description of an event, encoded as UTF-8 and containing no ASCII control characters or newlines.

×