BIND 10 trac901, updated. 7c40e60eeaad7f2c1ea79f92e866dee08eafd5ab [trac901] Some cleanups and documentation
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu May 5 16:44:01 UTC 2011
The branch, trac901 has been updated
via 7c40e60eeaad7f2c1ea79f92e866dee08eafd5ab (commit)
from fcc1b5e13946c5e58e2bd0bf287f551e161f0544 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7c40e60eeaad7f2c1ea79f92e866dee08eafd5ab
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu May 5 18:42:33 2011 +0200
[trac901] Some cleanups and documentation
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/logger.h | 12 +++++---
src/lib/log/logger_impl.cc | 23 ----------------
src/lib/log/logger_impl.h | 62 ++++---------------------------------------
src/lib/log/macros.h | 5 +++
4 files changed, 19 insertions(+), 83 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/log/logger.h b/src/lib/log/logger.h
index be54d86..6bd8924 100644
--- a/src/lib/log/logger.h
+++ b/src/lib/log/logger.h
@@ -49,9 +49,6 @@ class LoggerImpl; // Forward declaration of the implementation class
class Logger {
public:
- typedef isc::log::Formatter<Logger> Formatter;
- void output(const char* sevText, const std::string& message);
-
/// \brief Constructor
///
/// Creates/attaches to a logger of a specific name.
@@ -87,10 +84,11 @@ public:
loggerptr_(NULL), name_(name), infunc_(infunc)
{}
-
/// \brief Destructor
virtual ~Logger();
+ /// \brief The formatter used to replace placeholders
+ typedef isc::log::Formatter<Logger> Formatter;
/// \brief Get Name of Logger
///
@@ -204,6 +202,12 @@ protected:
static void reset();
private:
+ friend class isc::log::Formatter<Logger>;
+ /// \brief Raw output function
+ ///
+ /// This is used by the formatter to output formatted output.
+ void output(const char* sevText, const std::string& message);
+
/// \brief Copy Constructor
///
/// Disabled (marked private) as it makes no sense to copy the logger -
diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc
index ab0298a..a678735 100644
--- a/src/lib/log/logger_impl.cc
+++ b/src/lib/log/logger_impl.cc
@@ -215,28 +215,5 @@ LoggerImpl::outputRaw(const char* sevText, const string& message) {
message << endl;
}
-void
-LoggerImpl::output(const char* sev_text, const MessageID& ident,
- va_list ap)
-{
- char message[512]; // Should be large enough for any message
-
- // Obtain text of the message and substitute arguments.
- const string format = MessageDictionary::globalDictionary().getText(ident);
- vsnprintf(message, sizeof(message), format.c_str(), ap);
-
- // Get the time in a struct tm format, and convert to text
- time_t t_time;
- time(&t_time);
- struct tm* tm_time = localtime(&t_time);
-
- char chr_time[32];
- (void) strftime(chr_time, sizeof(chr_time), "%Y-%m-%d %H:%M:%S", tm_time);
-
- // Now output.
- std::cout << chr_time << " " << sev_text << " [" << getName() << "] " <<
- ident << ", " << message << "\n";
-}
-
} // namespace log
} // namespace isc
diff --git a/src/lib/log/logger_impl.h b/src/lib/log/logger_impl.h
index cee2483..187e478 100644
--- a/src/lib/log/logger_impl.h
+++ b/src/lib/log/logger_impl.h
@@ -167,66 +167,16 @@ public:
}
}
-
- /// \brief Output General Message
- ///
- /// The message is formatted to include the date and time, the severity
- /// and the logger generating the message.
+ /// \brief Raw output
///
- /// \param sev_text Severity level as a text string
- /// \param ident Message identification
- /// \param ap Variable argument list holding message arguments
- void output(const char* sev_text, const MessageID& ident,
- va_list ap);
-
+ /// Writes the message with time into the log. Used by the Formatter
+ /// to produce output.
void outputRaw(const char* sev_text, const std::string& message);
- std::string* lookupMessage(const MessageID& id);
-
- /// \brief Output Debug Message
- ///
- /// \param ident Message identification.
- /// \param text Text to log
- /// \param ap Variable argument list holding message arguments
- void debug(const MessageID& ident, va_list ap) {
- output("DEBUG", ident, ap);
- }
-
- /// \brief Output Informational Message
+ /// \brief Look up message text in dictionary
///
- /// \param ident Message identification.
- /// \param text Text to log
- /// \param ap Variable argument list holding message arguments
- void info(const MessageID& ident, va_list ap) {
- output("INFO ", ident, ap);
- }
-
- /// \brief Output Warning Message
- ///
- /// \param ident Message identification.
- /// \param text Text to log
- /// \param ap Variable argument list holding message arguments
- void warn(const MessageID& ident, va_list ap) {
- output("WARN ", ident, ap);
- }
-
- /// \brief Output Error Message
- ///
- /// \param ident Message identification.
- /// \param text Text to log
- /// \param ap Variable argument list holding message arguments
- void error(const MessageID& ident, va_list ap) {
- output("ERROR", ident, ap);
- }
-
- /// \brief Output Fatal Message
- ///
- /// \param ident Message identification.
- /// \param text Text to log
- /// \param ap Variable argument list holding message arguments
- void fatal(const MessageID& ident, va_list ap) {
- output("FATAL", ident, ap);
- }
+ /// This gets you the unformatted text of message for given ID.
+ std::string* lookupMessage(const MessageID& id);
/// \brief Equality
///
diff --git a/src/lib/log/macros.h b/src/lib/log/macros.h
index 7b4b497..4a5ac19 100644
--- a/src/lib/log/macros.h
+++ b/src/lib/log/macros.h
@@ -15,26 +15,31 @@
#ifndef __LOG_MACROS_H
#define __LOG_MACROS_H
+/// \brief Macro to conveniently test debug output and log it
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE) \
if (!(LOGGER).isDebugEnabled((LEVEL))) { \
} else \
(LOGGER).debug((LEVEL), (MESSAGE))
+/// \brief Macro to conveniently test info output and log it
#define LOG_INFO(LOGGER, MESSAGE) \
if (!(LOGGER).isInfoEnabled()) { \
} else \
(LOGGER).info((MESSAGE))
+/// \brief Macro to conveniently test warn output and log it
#define LOG_WARN(LOGGER, MESSAGE) \
if (!(LOGGER).isWarnEnabled()) { \
} else \
(LOGGER).warn((MESSAGE))
+/// \brief Macro to conveniently test error output and log it
#define LOG_ERROR(LOGGER, MESSAGE) \
if (!(LOGGER).isErrorEnabled()) { \
} else \
(LOGGER).error((MESSAGE))
+/// \brief Macro to conveniently test fatal output and log it
#define LOG_FATAL(LOGGER, MESSAGE) \
if (!(LOGGER).isFatalEnabled()) { \
} else \
More information about the bind10-changes
mailing list