Kea 2.7.6
|
Console Logger Implementation. More...
#include <logger_impl.h>
Public Member Functions | |
LoggerImpl (const std::string &name) | |
Constructor. | |
virtual | ~LoggerImpl () |
Destructor. | |
virtual int | getDebugLevel () |
Return debug level. | |
virtual int | getEffectiveDebugLevel () |
Return effective debug level. | |
virtual Severity | getEffectiveSeverity () |
Get Effective Severity Level for Logger. | |
virtual std::string | getName () |
Get the full name of the logger (including the root name) | |
virtual Severity | getSeverity () |
Get Severity Level for Logger. | |
bool | hasAppender (OutputOption::Destination const destination) |
Check if this logger has an appender of the given type. | |
virtual bool | isDebugEnabled (int dbglevel=MIN_DEBUG_LEVEL) |
Returns if Debug Message Should Be Output. | |
virtual bool | isErrorEnabled () |
Is ERROR Enabled? | |
virtual bool | isFatalEnabled () |
Is FATAL Enabled? | |
virtual bool | isInfoEnabled () |
Is INFO Enabled? | |
virtual bool | isWarnEnabled () |
Is WARNING Enabled? | |
boost::shared_ptr< std::string > | lookupMessage (const MessageID &id) |
Look up message text in dictionary. | |
bool | operator== (const LoggerImpl &other) const |
Equality. | |
void | outputRaw (const Severity &severity, const std::string &message) |
Raw output. | |
void | setInterprocessSync (isc::log::interprocess::InterprocessSync *sync) |
Replace the interprocess synchronization object. | |
virtual void | setSeverity (Severity severity, int dbglevel=1) |
Set Severity Level for Logger. | |
Static Public Member Functions | |
static std::string | getVersion () |
Version. | |
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 59 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 69 of file logger_impl.cc.
References isc::log::lockfileEnabled().
|
virtual |
Destructor.
Definition at line 82 of file logger_impl.cc.
|
virtual |
Return debug level.
Definition at line 111 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::dbglevel.
|
virtual |
Return effective debug level.
Definition at line 127 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 119 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 79 of file logger_impl.h.
|
virtual |
Get Severity Level for Logger.
Definition at line 104 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertToBindLevel(), and isc::log::Level::severity.
|
static |
Version.
Definition at line 88 of file logger_impl.cc.
Referenced by isc::log::Logger::getVersion().
bool isc::log::LoggerImpl::hasAppender | ( | OutputOption::Destination const | destination | ) |
Check if this logger has an appender of the given type.
destination | the appender type to be checked: console, file or syslog |
Definition at line 203 of file logger_impl.cc.
References isc::log::OutputOption::DEST_CONSOLE, isc::log::OutputOption::DEST_FILE, isc::log::OutputOption::DEST_SYSLOG, and isc::log::getRootLoggerName().
Referenced by isc::log::Logger::hasAppender().
|
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 130 of file logger_impl.h.
References isc::log::LoggerLevelImpl::convertFromBindLevel(), and isc::log::DEBUG.
|
inlinevirtual |
Is ERROR Enabled?
Definition at line 146 of file logger_impl.h.
|
inlinevirtual |
Is FATAL Enabled?
Definition at line 151 of file logger_impl.h.
|
inlinevirtual |
Is INFO Enabled?
Definition at line 136 of file logger_impl.h.
|
inlinevirtual |
Is WARNING Enabled?
Definition at line 141 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 135 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 194 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 154 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 143 of file logger_impl.cc.
References isc_throw.
Referenced by isc::log::Logger::setInterprocessSync().
|
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 97 of file logger_impl.cc.
References isc::log::LoggerLevelImpl::convertFromBindLevel().
Referenced by isc::log::Logger::setSeverity().