Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::Logger Class Reference

#include <Logger.h>

Inheritance diagram for Poco::Logger:

Poco::Channel Poco::Configurable Poco::RefCountedObject

List of all members.


Detailed Description

Logger is a special Channel that acts as the main entry point into the logging framework.

An application uses instances of the Logger class to generate its log messages and send them on their way to their final destination. Logger instances are organized in a hierarchical, tree-like manner and are maintained by the framework. Every Logger object has exactly one direct ancestor, with the exception of the root logger. A newly created logger inherits its properties - channel and level - from its direct ancestor. Every logger is connected to a channel, to which it passes on its messages. Furthermore, every logger has a log level, which is used for filtering messages based on their priority. Only messages with a priority equal to or higher than the specified level are passed on. For example, if the level of a logger is set to three (PRIO_ERROR), only messages with priority PRIO_ERROR, PRIO_CRITICAL and PRIO_FATAL will propagate. If the level is set to zero, the logger is effectively disabled.

The name of a logger determines the logger's place within the logger hierarchy. The name of the root logger is always "", the empty string. For all other loggers, the name is made up of one or more components, separated by a period. For example, the loggers with the name HTTPServer.RequestHandler and HTTPServer.Listener are descendants of the logger HTTPServer, which itself is a descendant of the root logger. There is not limit as to how deep the logger hierarchy can become. Once a logger has been created and it has inherited the channel and level from its ancestor, it loses the connection to it. So changes to the level or channel of a logger do not affect its descendants. This greatly simplifies the implementation of the framework and is no real restriction, because almost always levels and channels are set up at application startup and never changed afterwards. Nevertheless, there are methods to simultaneously change the level and channel of all loggers in a certain hierarchy.

Definition at line 57 of file Logger.h.


Public Member Functions

virtual void close ()
bool critical () const
 Returns true if the log level is at least PRIO_FATAL.
void critical (const std::string &msg)
bool debug () const
 Returns true if the log level is at least PRIO_INFORMATION.
void debug (const std::string &msg)
void dump (const std::string &msg, const void *buffer, std::size_t length, Message::Priority prio=Message::PRIO_DEBUG)
void duplicate () const
bool error () const
 Returns true if the log level is at least PRIO_CRITICAL.
void error (const std::string &msg)
bool fatal () const
 Returns true if at least the given log level is set.
void fatal (const std::string &msg)
 Logs the given exception with priority PRIO_ERROR.
ChannelgetChannel () const
 Attaches the given Channel to the Logger.
int getLevel () const
 Sets the Logger's log level.
std::string getProperty (const std::string &name) const
 Throws a PropertyNotSupportedException.
bool information () const
 Returns true if the log level is at least PRIO_NOTICE.
void information (const std::string &msg)
bool is (int level) const
void log (const Exception &exc)
void log (const Message &msg)
const std::string & name () const
bool notice () const
 Returns true if the log level is at least PRIO_WARNING.
void notice (const std::string &msg)
virtual void open ()
int referenceCount () const
void release () const
 Increments the object's reference count.
void setChannel (Channel *pChannel)
void setLevel (const std::string &level)
 Returns the Logger's log level.
void setLevel (int level)
 Returns the Channel attached to the logger.
void setProperty (const std::string &name, const std::string &value)
bool trace () const
 Returns true if the log level is at least PRIO_DEBUG.
void trace (const std::string &msg)
bool warning () const
 Returns true if the log level is at least PRIO_ERROR.
void warning (const std::string &msg)

Static Public Member Functions

static Loggercreate (const std::string &name, Channel *pChannel, int level=Message::PRIO_INFORMATION)
static void destroy (const std::string &name)
static std::string format (const std::string &fmt, const std::string &arg0, const std::string &arg1, const std::string &arg2, const std::string &arg3)
static std::string format (const std::string &fmt, const std::string &arg0, const std::string &arg1, const std::string &arg2)
static std::string format (const std::string &fmt, const std::string &arg0, const std::string &arg1)
static std::string format (const std::string &fmt, const std::string &arg)
 Returns true if the log level is at least PRIO_TRACE.
static Loggerget (const std::string &name)
static Loggerhas (const std::string &name)
static void names (std::vector< std::string > &names)
static Loggerroot ()
static void setChannel (const std::string &name, Channel *pChannel)
static void setLevel (const std::string &name, int level)
static void setProperty (const std::string &loggerName, const std::string &propertyName, const std::string &value)
static void shutdown ()
static LoggerunsafeGet (const std::string &name)

Static Public Attributes

static const std::string ROOT

Protected Types

typedef std::map< std::string,
Logger * > 
LoggerMap
 The name of the root logger ("").

Protected Member Functions

void log (const std::string &text, Message::Priority prio)
 Logger (const std::string &name, Channel *pChannel, int level)

Static Protected Member Functions

static void add (Logger *pLogger)
static Loggerfind (const std::string &name)
static std::string format (const std::string &fmt, int argc, std::string argv[])
static void formatDump (std::string &message, const void *buffer, std::size_t length)
static Loggerparent (const std::string &name)

Private Member Functions

 Logger (const Logger &)
Loggeroperator= (const Logger &)

Private Attributes

int _level
std::string _name
Channel_pChannel

Static Private Attributes

static Mutex _mapMtx
static LoggerMap_pLoggerMap = 0

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

Generated by  Doxygen 1.6.0   Back to index