Kea
1.9.9-git
|
Console Logger Implementation. More...
#include <logger_impl.h>
Public Member Functions | |
LoggerImpl (const std::string &name) | |
Constructor. More... | |
virtual | ~LoggerImpl () |
Destructor. More... | |
virtual int | getDebugLevel () |
Return debug level. More... | |
virtual int | getEffectiveDebugLevel () |
Return effective debug level. More... | |
virtual Severity | getEffectiveSeverity () |
Get Effective Severity Level for Logger. More... | |
virtual std::string | getName () |
Get the full name of the logger (including the root name) More... | |
virtual Severity | getSeverity () |
Get Severity Level for Logger. More... | |
virtual bool | isDebugEnabled (int dbglevel=MIN_DEBUG_LEVEL) |
Returns if Debug Message Should Be Output. More... | |
virtual bool | isErrorEnabled () |
Is ERROR Enabled? More... | |
virtual bool | isFatalEnabled () |
Is FATAL Enabled? More... | |
virtual bool | isInfoEnabled () |
Is INFO Enabled? More... | |
virtual bool | isWarnEnabled () |
Is WARNING Enabled? More... | |
boost::shared_ptr< std::string > | lookupMessage (const MessageID &id) |
Look up message text in dictionary. More... | |
bool | operator== (const LoggerImpl &other) |
Equality. More... | |
void | outputRaw (const Severity &severity, const std::string &message) |
Raw output. More... | |
void | setInterprocessSync (isc::log::interprocess::InterprocessSync *sync) |
Replace the interprocess synchronization object. More... | |
virtual void | setSeverity (Severity severity, int dbglevel=1) |
Set Severity Level for Logger. More... | |
Static Public Member Functions | |
static std::string | getVersion () |
Version. More... | |
Console Logger Implementation.
The logger uses a "pimpl" idiom for implementation, where the base logger class contains little more than a pointer to the implementation class, and all actions are carried out by the latter.
This particular implementation is based on log4cplus (from sourceforge: http://log4cplus.sourceforge.net). Particular items of note:
a) Kea loggers have names of the form "program.sublogger". In other words, each of the loggers is a sub-logger of the main program logger. In log4cplus, there is a root logger (called "root" according to the documentation, but actually unnamed) and all loggers created are subloggers if it.
In this implementation, the log4cplus root logger is unused. Instead, the Kea root logger is created as a child of the log4cplus root logger, and all other loggers used in the program are created as sub-loggers of that. In this way, the logging system can just include the name of the logger in each message without the need to specially consider if the message is the root logger or not.
b) The idea of debug levels is implemented. See logger_level.h and logger_level_impl.h for more details on this.
Definition at line 58 of file logger_impl.h.
isc::log::LoggerImpl::LoggerImpl | ( | const std::string & | name | ) |
Constructor.
Creates a logger of the specific name.
name | Name of the logger. |
Definition at line 68 of file logger_impl.cc.
References isc::log::lockfileEnabled().
|
virtual |
Destructor.
Definition at line 81 of file logger_impl.cc.
|
virtual |
Return debug level.
Definition at line 110 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::dbglevel.
|
virtual |
Return effective debug level.
Definition at line 126 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::dbglevel.
|
virtual |
Get Effective Severity Level for Logger.
Definition at line 118 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::severity.
|
inlinevirtual |
Get the full name of the logger (including the root name)
Definition at line 78 of file logger_impl.h.
|
virtual |
Get Severity Level for Logger.
Definition at line 103 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::severity.
|
static |
Version.
Definition at line 87 of file logger_impl.cc.
|
inlinevirtual |
Returns if Debug Message Should Be Output.
dbglevel | Level for which debugging is checked. Debugging is enabled only if the logger has DEBUG enabled and if the dbglevel checked is less than or equal to the debug level set for the logger. |
Definition at line 129 of file logger_impl.h.
References isc::log::LoggerLevelImpl::convertFromBindLevel(), and isc::log::DEBUG.
|
inlinevirtual |
Is ERROR Enabled?
Definition at line 145 of file logger_impl.h.
|
inlinevirtual |
Is FATAL Enabled?
Definition at line 150 of file logger_impl.h.
|
inlinevirtual |
Is INFO Enabled?
Definition at line 135 of file logger_impl.h.
|
inlinevirtual |
Is WARNING Enabled?
Definition at line 140 of file logger_impl.h.
boost::shared_ptr< string > isc::log::LoggerImpl::lookupMessage | ( | const MessageID & | id | ) |
Look up message text in dictionary.
This gets you the unformatted text of message for given ID.
Definition at line 134 of file logger_impl.cc.
References isc::log::MessageDictionary::globalDictionary().
|
inline |
Equality.
Check if two instances of this logger refer to the same stream. (This method is principally for testing.)
Definition at line 186 of file logger_impl.h.
void isc::log::LoggerImpl::outputRaw | ( | const Severity & | severity, |
const std::string & | message | ||
) |
Raw output.
Writes the message with time into the log. Used by the Formatter to produce output.
severity | Severity of the message. (This controls the prefix label output with the message text.) |
message | Text of the message. |
Definition at line 153 of file logger_impl.cc.
References isc::log::DEBUG, isc::log::ERROR, isc::log::FATAL, isc::log::LoggerManager::getMutex(), isc::log::INFO, isc::log::interprocess::InterprocessSyncLocker::lock(), isc::log::NONE, isc::log::interprocess::InterprocessSyncLocker::unlock(), and isc::log::WARN.
void isc::log::LoggerImpl::setInterprocessSync | ( | isc::log::interprocess::InterprocessSync * | sync | ) |
Replace the interprocess synchronization object.
If this method is called with NULL as the argument, it throws a BadInterprocessSync exception.
sync | The logger uses this synchronization object for synchronizing output of log messages. It should be deletable and the ownership is transferred to the logger implementation. If NULL is passed, a BadInterprocessSync exception is thrown. |
Definition at line 142 of file logger_impl.cc.
References isc_throw.
|
virtual |
Set Severity Level for Logger.
Sets the level at which this logger will log messages. If none is set, the level is inherited from the parent.
severity | Severity level to log |
dbglevel | If the severity is DEBUG, this is the debug level. This can be in the range 0 to 99 and controls the verbosity. A value outside these limits is silently coerced to the nearest boundary. |
Definition at line 96 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertFromBindLevel().