Exiv2
Public Types | Static Public Member Functions

Exiv2::LogMsg Class Reference

Class for a log message, used by the library. Applications can set the log level and provide a customer log message handler (callback function). More...

#include <error.hpp>

Collaboration diagram for Exiv2::LogMsg:

List of all members.

Public Types

enum  Level {
  debug = 0, info = 1, warn = 2, error = 3,
  mute = 4
}
 

Defined log levels. To suppress all log messages, either set the log level to mute or set the log message handler to 0.


typedef void(* Handler )(int, const char *)
 Type for a log message handler function. The function receives the log level and message and can process it in an application specific way. The default handler sends the log message to standard error.

Public Member Functions

Creators
 LogMsg (Level msgType)
 Constructor, takes the log message type as an argument.
 ~LogMsg ()
 Destructor, passes the log message to the message handler depending on the log level.
Manipulators
template<typename T >
LogMsgoperator<< (const T &t)
 Output operator, to pass the message to a log message object. (This is not perfect. It can deal with some std manipulators but not all, e.g., not std::endl.)

Static Public Member Functions

static void setLevel (Level level)
 Set the log level. Only log messages with a level greater or equal level are sent to the log message handler. Default log level is info. To suppress all log messages, set the log level to mute (or set the log message handler to 0).
static void setHandler (Handler handler)
 Set the log message handler. The default handler writes log messages to standard error. To suppress all log messages, set the log message handler to 0 (or set the log level to mute).
static Level level ()
 Return the current log level.
static Handler handler ()
 Return the current log message handler.
static void defaultHandler (int level, const char *s)
 The default log handler. Sends the log message to standard error.

Detailed Description

Class for a log message, used by the library. Applications can set the log level and provide a customer log message handler (callback function).

This class is meant to be used as a temporary object like this:

LogMsg(LogMsg::warn) << "Warning! Something looks fishy.\n";

The convenience macros EXV_DEBUG, EXV_INFO, EXV_WARN and EXV_ERROR are just shorthands for the constructor calls.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines