Qpid C++ Messaging API  1.39.0
qpid::messaging::Logger Class Reference

#include <Logger.h>

Static Public Member Functions

static QPID_MESSAGING_EXTERN void configure (int argc, const char *argv[], const std::string &prefix=std::string())
 
static QPID_MESSAGING_EXTERN std::string usage ()
 
static QPID_MESSAGING_EXTERN void setOutput (LoggerOutput &output)
 
static QPID_MESSAGING_EXTERN void log (Level level, const char *file, int line, const char *function, const std::string &message)
 

Detailed Description

A utility class to allow the application to control the logging output of the qpid messaging library

This class represents a singleton logging facility within the qpid messaging library so there are only static methods in the class

Member Function Documentation

◆ configure()

static QPID_MESSAGING_EXTERN void qpid::messaging::Logger::configure ( int  argc,
const char *  argv[],
const std::string &  prefix = std::string() 
)
static

Configure the logging subsystem

This function takes an array of text options (which could easily come from a programs command line) and uses them to configure the logging subsystem.

If the prefix parameter is specified then the accepted command line options are prefixed by <<prefix>>- for example if the prefix is "qpid" then the options all start "--qpid-log..."

Accepted options are: –log-enable RULE –log-disable RULE

Both –log-enable and –log-disable can be specified multiple times in a single command line. The enables are acted upon and after them the disables are acted upon.

RULE is in the form LEVEL[("+"|"-")][:PATTERN] LEVEL is one of "trace", "debug", "info", "notice", "warning", "error", "critical" "+" operates on the level and all higher levels "-" operates on the level and all lower levels PATTERN is a category name or a fragment of a fully namespace qualified function (Case sensitive).

–log-to-stdout ("on"|"off|"0"|"1") --log-to-stderr ("on"|"off|"0"|"1") –log-to-file FILENAME

These options control where the qpid logging subsystem sends log messages

–log-time ("on"|"off|"0"|"1") --log-level ("on"|"off|"0"|"1") –log-source ("on"|"off|"0"|"1") --log-thread ("on"|"off|"0"|"1") –log-function ("on"|"off|"0"|"1") --log-hires-timestamp ("on"|"off|"0"|"1")

These options control what information is included in the logging message sent by the logging subsystem.

Parameters
argccount of options - identical to meaning for main().
argvarray of pointers to options - identical to meaning for main().
prefix(optional) If present prefix all logging options with this string
Exceptions
MessagingExceptionif it cannot parse an option it recognises

◆ log()

static QPID_MESSAGING_EXTERN void qpid::messaging::Logger::log ( Level  level,
const char *  file,
int  line,
const char *  function,
const std::string &  message 
)
static

Output a log message. This will get sent to all the specified logging outputs including any the application has registered. The message will get filtered along with the internal messages according to the specified logging filters.

When a log message output using log() is received by a LoggerOutput::log() method the "user" bool parameter will be set true.

◆ setOutput()

static QPID_MESSAGING_EXTERN void qpid::messaging::Logger::setOutput ( LoggerOutput output)
static

Register a custom handler for log messages

This allows application programs to intercept the log messages coming from qpid::messaging and handle them in whatever way is consonent with the applications own handling of log messages.

In order to do this create a class that inherits from qpid::messaging::LoggerOutput and override the log() member function.

◆ usage()

static QPID_MESSAGING_EXTERN std::string qpid::messaging::Logger::usage ( )
static

Get a user friendly usage message.

This returns a usage message that is suitable for outputting directly to a console user. The message only contains the command line options that are understood by qpid::messaging::Logger::configure().

NB. You must call qpid::messaging::Logger::configure() before calling this to populate the usage string as the usage string depends on the prefix that is passed in to qpid::messaging::Logger::configure().

Returns
string containing the usage message for the command line options

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