Log

class kanzi::connect::Log

A class that allows to output text to different destinations during runtime.

Public Types

enum Category

Log categories that can be enabled and disabled at runtime Used now only when logging traces.

Values:

enumerator General

General category, is now always enabled.

enumerator ConnectionManagerTrace

Connection Manager traces.

enumerator AbstractServiceTrace

Abstract Service traces.

enumerator WorkQueueTrace

Work Queue traces.

enumerator NetworkListenerTrace

Network Listener traces.

enumerator LogCategoryCount

This must be last item, should contain count of items in this enum!

enum Destination

Type of destination where log is outputted.

Values:

enumerator File

Write log to file.

enumerator Debugger

Write log to debugger.

enumerator StandardOutput

Write log to standard output.

enumerator Callback

Output to callback.

enumerator Diagnostics

This flag defines whether log is to be routed from a client to server.

typedef bitset<LogCategoryCount> LogActiveCategories

Container for active log categories.

typedef function<void(const string &message)> LogCallbackFunction

Callback function, invoked when query is completed.

typedef function<void(int level, const string &stamp, const string &tag, const string &message)> LogDiagnosticsCallbackFunction

callback function - invoked for each and every log line to be written.

Mainly used by the diagnostics functionality.

Public Functions

Log()

Constructor.

~Log()

Destructor.

Public Static Functions

static bool categoryEnabled(Log::Category category)

Is log category enabled.

Return

true if enabled and allowed to log.

static void disableCategory(Log::Category category)

Disable logging category.

See Log::Category for available categories.

Parameters
  • category: the log category

static void enableCategory(Log::Category category)

Enable logging category.

See Log::Category for available categories.

Parameters
  • category: the log category

static int getDestination()

Retrieves current log destination flags.

Return

Combination of flags that define current log destination.

static LogLevel getLevel()

Retrieves current logging level, log messages will be ignored if they don’t meet this level.

Return

Current log level.

static int getLevelEx()

Retrieves current log level.

Intended to be used from external language bindings (android).

Return

Current log level.

static uint32_t getLoggedFeatures()

Retrieve the logged features.

Return

the flags that indicate logged features. See LoggerBase::Feature* enum.

static Log &getSingleton()

Access to singleton instance of the logger.

static void pushLogger(kanzi::AbstractLogger *loggerInstance)

Adds an user specific logger.

Parameters
  • loggerInstance: the logger to add. Ownership of the pointer transfers.

static void setCallback(LogCallbackFunction callback)

Sets callback for log output.

Parameters
  • callback: Log callback function, that is invoked whenever theres a new log message.

static void setDestination(int destination)

Sets log destination.

Parameters
  • destination: Log destination, can be a combination of multiple destinations (ie. Debugger|StandardOutput).

static void setDiagnosticsCallback(LogDiagnosticsCallbackFunction callback)

sets a diagnostics callback function that get(s) called for each and every log write.

Parameters
  • callback: pointer to functor object.

static void setLevel(LogLevel level)

Sets logging level, log messages will be ignored if they don’t meet this level.

Parameters
  • level: New log level.

static void setLevelEx(int level)

Sets logging level.

Intended to be used from external language bindings (android).

Parameters
  • level: new level.

static void setLoggedFeatures(uint32_t features)

Configure the logged features.

Parameters
  • features: bitmaps of LoggerBase::Feature* flags.