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

bool categoryEnabled(Log::Category category)

Is log category enabled.

Return

true if enabled and allowed to log.

void disableCategory(Log::Category category)

Disable logging category.

See Log::Category for available categories.

Parameters
  • category: the log category

void enableCategory(Log::Category category)

Enable logging category.

See Log::Category for available categories.

Parameters
  • category: the log category

int getDestination()

Retrieves current log destination flags.

Return

Combination of flags that define current log destination.

LogLevel getLevel()

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

Return

Current log level.

int getLevelEx()

Retrieves current log level.

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

Return

Current log level.

uint32_t getLoggedFeatures()

Retrieve the logged features.

Return

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

Log &getSingleton()

Access to singleton instance of the logger.

void pushLogger(kanzi::AbstractLogger *loggerInstance)

Adds an user specific logger.

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

void setCallback(LogCallbackFunction callback)

Sets callback for log output.

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

void setDestination(int destination)

Sets log destination.

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

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.

void setLevel(LogLevel level)

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

Parameters
  • level: New log level.

void setLevelEx(int level)

Sets logging level.

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

Parameters
  • level: new level.

void setLoggedFeatures(uint32_t features)

Configure the logged features.

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