Kanzi Connect 3.9.10
kanzi::connect::Log Class Reference

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

#include <log.hpp>

Public Types

enum  Category {
  General = 0 , ConnectionManagerTrace , AbstractServiceTrace , WorkQueueTrace ,
  NetworkListenerTrace , LogCategoryCount
}
 Log categories that can be enabled and disabled at runtime Used now only when logging traces. More...
 
enum  Destination {
  File = 0x1 , Debugger = 0x2 , StandardOutput = 0x4 , Callback = 0x8 ,
  Diagnostics = 0x8000
}
 Type of destination where log is outputted. More...
 
typedef bitset< LogCategoryCountLogActiveCategories
 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.
 

Public Member Functions

 Log ()
 Constructor.
 
 ~Log ()
 Destructor.
 

Static Public Member Functions

static bool categoryEnabled (Log::Category category)
 Is log category enabled.
 
static void disableCategory (Log::Category category)
 Disable logging category.
 
static void enableCategory (Log::Category category)
 Enable logging category.
 
static int getDestination ()
 Retrieves current log destination flags.
 
static LogLevel getLevel ()
 Retrieves current logging level, log messages will be ignored if they don't meet this level.
 
static int getLevelEx ()
 Retrieves current log level.
 
static uint32_t getLoggedFeatures ()
 Retrieve the logged features.
 
static LoggetSingleton ()
 Access to singleton instance of the logger.
 
static void pushLogger (kanzi::AbstractLogger *loggerInstance)
 Adds an user specific logger.
 
static void setCallback (LogCallbackFunction callback)
 Sets callback for log output.
 
static void setDestination (int destination)
 Sets log destination.
 
static void setDiagnosticsCallback (LogDiagnosticsCallbackFunction callback)
 sets a diagnostics callback function that get(s) called for each and every log write.
 
static void setLevel (LogLevel level)
 Sets logging level, log messages will be ignored if they don't meet this level.
 
static void setLevelEx (int level)
 Sets logging level.
 
static void setLoggedFeatures (uint32_t features)
 Configure the logged features.
 

Protected Member Functions

void setDestinationInternal (int flags)
 Sets the destination.
 

Detailed Description

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

Member Typedef Documentation

◆ LogActiveCategories

Container for active log categories.

◆ LogCallbackFunction

typedef function<void(const string& message) kanzi::connect::Log::LogCallbackFunction)

Callback function, invoked when query is completed.

◆ LogDiagnosticsCallbackFunction

typedef function<void(int level, const string& stamp, const string& tag, const string& message) kanzi::connect::Log::LogDiagnosticsCallbackFunction)

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

Mainly used by the diagnostics functionality.

Member Enumeration Documentation

◆ Category

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

Enumerator
General 

General category, is now always enabled.

ConnectionManagerTrace 

Connection Manager traces.

AbstractServiceTrace 

Abstract Service traces.

WorkQueueTrace 

Work Queue traces.

NetworkListenerTrace 

Network Listener traces.

LogCategoryCount 

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

◆ Destination

Type of destination where log is outputted.

Enumerator
File 

Write log to file.

Debugger 

Write log to debugger.

StandardOutput 

Write log to standard output.

Callback 

Output to callback.

Diagnostics 

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

Constructor & Destructor Documentation

◆ Log()

kanzi::connect::Log::Log ( )

Constructor.

◆ ~Log()

kanzi::connect::Log::~Log ( )

Destructor.

Member Function Documentation

◆ categoryEnabled()

static bool kanzi::connect::Log::categoryEnabled ( Log::Category category)
static

Is log category enabled.

Returns
true if enabled and allowed to log.

◆ disableCategory()

static void kanzi::connect::Log::disableCategory ( Log::Category category)
static

Disable logging category.

See Log::Category for available categories.

Parameters
categorythe log category

◆ enableCategory()

static void kanzi::connect::Log::enableCategory ( Log::Category category)
static

Enable logging category.

See Log::Category for available categories.

Parameters
categorythe log category

◆ getDestination()

static int kanzi::connect::Log::getDestination ( )
static

Retrieves current log destination flags.

Returns
Combination of flags that define current log destination.

◆ getLevel()

static LogLevel kanzi::connect::Log::getLevel ( )
static

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

Returns
Current log level.

◆ getLevelEx()

static int kanzi::connect::Log::getLevelEx ( )
static

Retrieves current log level.

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

Returns
Current log level.

◆ getLoggedFeatures()

static uint32_t kanzi::connect::Log::getLoggedFeatures ( )
static

Retrieve the logged features.

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

◆ getSingleton()

static Log & kanzi::connect::Log::getSingleton ( )
static

Access to singleton instance of the logger.

◆ pushLogger()

static void kanzi::connect::Log::pushLogger ( kanzi::AbstractLogger * loggerInstance)
static

Adds an user specific logger.

Parameters
loggerInstancethe logger to add. Ownership of the pointer transfers.

◆ setCallback()

static void kanzi::connect::Log::setCallback ( LogCallbackFunction callback)
static

Sets callback for log output.

Parameters
callbackLog callback function, that is invoked whenever theres a new log message.

◆ setDestination()

static void kanzi::connect::Log::setDestination ( int destination)
static

Sets log destination.

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

◆ setDestinationInternal()

void kanzi::connect::Log::setDestinationInternal ( int flags)
protected

Sets the destination.

Parameters
flagsnew destinations to set.

◆ setDiagnosticsCallback()

static void kanzi::connect::Log::setDiagnosticsCallback ( LogDiagnosticsCallbackFunction callback)
static

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

Parameters
callbackpointer to functor object.

◆ setLevel()

static void kanzi::connect::Log::setLevel ( LogLevel level)
static

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

Parameters
levelNew log level.

◆ setLevelEx()

static void kanzi::connect::Log::setLevelEx ( int level)
static

Sets logging level.

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

Parameters
levelnew level.

◆ setLoggedFeatures()

static void kanzi::connect::Log::setLoggedFeatures ( uint32_t features)
static

Configure the logged features.

Parameters
featuresbitmaps of LoggerBase::Feature* flags.

The documentation for this class was generated from the following file: