BIND 10 trac558, updated. 0d1efe0f87c1868ff5389c731dbfa7ead9416655 [trac558] Fixes after review
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Feb 14 11:19:43 UTC 2011
The branch, trac558 has been updated
via 0d1efe0f87c1868ff5389c731dbfa7ead9416655 (commit)
from 7abd3c8866212a9c29920ee82be7390ab2499c43 (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 0d1efe0f87c1868ff5389c731dbfa7ead9416655
Author: Stephen Morris <stephen at isc.org>
Date: Mon Feb 14 11:18:20 2011 +0000
[trac558] Fixes after review
Further changes after review. Also removed some includes of
<iostream> left over from debugging.
-----------------------------------------------------------------------
Summary of changes:
src/lib/log/compiler/message.cc | 2 +-
src/lib/log/logger.cc | 2 --
src/lib/log/logger_impl.cc | 2 --
src/lib/log/logger_impl.h | 1 -
src/lib/log/logger_support.cc | 2 +-
src/lib/log/logger_support.h | 4 ++--
src/lib/log/message_dictionary.cc | 2 --
src/lib/log/message_reader.h | 1 -
src/lib/log/messagedef.cc | 4 ++--
src/lib/log/messagedef.h | 2 +-
src/lib/log/root_logger_name.cc | 22 ++++++++++++++++------
src/lib/log/root_logger_name.h | 19 ++++++++++++-------
src/lib/log/strutil.cc | 1 -
src/lib/log/tests/logger_support_test.cc | 14 +++++++-------
14 files changed, 42 insertions(+), 36 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/log/compiler/message.cc b/src/lib/log/compiler/message.cc
index 769fbff..e3c0f91 100644
--- a/src/lib/log/compiler/message.cc
+++ b/src/lib/log/compiler/message.cc
@@ -391,7 +391,7 @@ writeProgramFile(const string& file, const string& prefix,
" NULL\n" <<
"};\n" <<
"\n" <<
- "isc::log::MessageInitializer initializer(values);\n" <<
+ "const isc::log::MessageInitializer initializer(values);\n" <<
"\n" <<
"} // Anonymous namespace\n" <<
"\n";
diff --git a/src/lib/log/logger.cc b/src/lib/log/logger.cc
index 731fbdd..cf46741 100644
--- a/src/lib/log/logger.cc
+++ b/src/lib/log/logger.cc
@@ -12,8 +12,6 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE
-#include <iostream>
-
#include <stdarg.h>
#include <stdio.h>
diff --git a/src/lib/log/logger_impl.cc b/src/lib/log/logger_impl.cc
index 447b7f4..4f897d4 100644
--- a/src/lib/log/logger_impl.cc
+++ b/src/lib/log/logger_impl.cc
@@ -203,7 +203,6 @@ LoggerImpl::output(const char* sev_text, const MessageID& ident,
// Obtain text of the message and substitute arguments.
const string format = MessageDictionary::globalDictionary().getText(ident);
vsnprintf(message, sizeof(message), format.c_str(), ap);
- message[sizeof(message) - 1] = '\0'; // Guarantee trailing NULL
// Get the time in a struct tm format, and convert to text
time_t t_time;
@@ -212,7 +211,6 @@ LoggerImpl::output(const char* sev_text, const MessageID& ident,
char chr_time[32];
(void) strftime(chr_time, sizeof(chr_time), "%Y-%m-%d %H:%M:%S", tm_time);
- chr_time[sizeof(chr_time) - 1] = '\0'; // Guarantee a trailing NULL
// Now output.
std::cout << chr_time << " " << sev_text << " [" << getName() << "] " <<
diff --git a/src/lib/log/logger_impl.h b/src/lib/log/logger_impl.h
index 2e45bfd..9fc9cf9 100644
--- a/src/lib/log/logger_impl.h
+++ b/src/lib/log/logger_impl.h
@@ -19,7 +19,6 @@
#include <time.h>
#include <cstdlib>
-#include <iostream>
#include <string>
#include <map>
#include <utility>
diff --git a/src/lib/log/logger_support.cc b/src/lib/log/logger_support.cc
index 73d336a..55de046 100644
--- a/src/lib/log/logger_support.cc
+++ b/src/lib/log/logger_support.cc
@@ -94,7 +94,7 @@ readLocalMessageFile(const char* file) {
/// Logger Run-Time Initialization
void
-init(const string& root, isc::log::Severity severity, int dbglevel,
+initLogger(const string& root, isc::log::Severity severity, int dbglevel,
const char* file) {
// Create the application root logger and set the default severity and
diff --git a/src/lib/log/logger_support.h b/src/lib/log/logger_support.h
index a8686f7..57d8383 100644
--- a/src/lib/log/logger_support.h
+++ b/src/lib/log/logger_support.h
@@ -36,8 +36,8 @@ namespace log {
/// \param severity Severity at which to log
/// \param dbglevel Debug severiy (ignored if "severity" is not "DEBUG")
/// \param file Name of the local message file.
-void init(const std::string& root, isc::log::Severity severity, int dbglevel,
- const char* file);
+void initLogger(const std::string& root, isc::log::Severity severity,
+ int dbglevel, const char* file);
} // namespace log
} // namespace isc
diff --git a/src/lib/log/message_dictionary.cc b/src/lib/log/message_dictionary.cc
index 85046bd..920c494 100644
--- a/src/lib/log/message_dictionary.cc
+++ b/src/lib/log/message_dictionary.cc
@@ -12,8 +12,6 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-#include <iostream>
-
#include <cstddef>
#include <log/message_dictionary.h>
#include <log/message_types.h>
diff --git a/src/lib/log/message_reader.h b/src/lib/log/message_reader.h
index bd1849c..d07c7f2 100644
--- a/src/lib/log/message_reader.h
+++ b/src/lib/log/message_reader.h
@@ -15,7 +15,6 @@
#ifndef __MESSAGE_READER_H
#define __MESSAGE_READER_H
-#include <iostream>
#include <map>
#include <string>
#include <vector>
diff --git a/src/lib/log/messagedef.cc b/src/lib/log/messagedef.cc
index 9c7d9ca..f680a74 100644
--- a/src/lib/log/messagedef.cc
+++ b/src/lib/log/messagedef.cc
@@ -1,4 +1,4 @@
-// File created from messagedef.mes on Wed Feb 9 16:55:11 2011
+// File created from messagedef.mes on Mon Feb 14 11:07:45 2011
#include <cstddef>
#include <log/message_types.h>
@@ -51,7 +51,7 @@ const char* values[] = {
NULL
};
-isc::log::MessageInitializer initializer(values);
+const isc::log::MessageInitializer initializer(values);
} // Anonymous namespace
diff --git a/src/lib/log/messagedef.h b/src/lib/log/messagedef.h
index dda43d6..eb8f4ea 100644
--- a/src/lib/log/messagedef.h
+++ b/src/lib/log/messagedef.h
@@ -1,4 +1,4 @@
-// File created from messagedef.mes on Wed Feb 9 16:55:11 2011
+// File created from messagedef.mes on Mon Feb 14 11:07:45 2011
#ifndef __MESSAGEDEF_H
#define __MESSAGEDEF_H
diff --git a/src/lib/log/root_logger_name.cc b/src/lib/log/root_logger_name.cc
index fcb0f2a..b8362b9 100644
--- a/src/lib/log/root_logger_name.cc
+++ b/src/lib/log/root_logger_name.cc
@@ -18,17 +18,27 @@
namespace isc {
namespace log {
-static std::string root_name_;
+namespace {
+
+// Obtain the root logger name in a way that is safe for statically-initialized
+// objects.
+
+std::string&
+getRootLoggerNameInternal() {
+ static std::string root_name;
+ return (root_name);
+}
+
+} // Anonymous namespace
void
setRootLoggerName(const std::string& name) {
- root_name_ = name;
+ getRootLoggerNameInternal() = name;
}
const std::string& getRootLoggerName() {
- return root_name_;
+ return getRootLoggerNameInternal();
}
-
-}
-}
+} // namespace log
+} // namespace isc
diff --git a/src/lib/log/root_logger_name.h b/src/lib/log/root_logger_name.h
index dc92ad5..29537fa 100644
--- a/src/lib/log/root_logger_name.h
+++ b/src/lib/log/root_logger_name.h
@@ -19,20 +19,25 @@
/// \brief Define Name of Root Logger
///
-/// In the log4cxx system, the root logger is ".". The definition for the
-/// BIND-10 system is that the root logger of a program has the name of the
-/// program. This (trivial) class stores the name of the program in a
-/// location accessible to the logger classes.
+/// IN BIND-10, the name root logger of a program is the name of the program
+/// itself (in contrast to packages such as log4cxx where the root logger name
+// is something like "."). These trivial functions allow the setting and
+// getting of that name by the logger classes.
namespace isc {
namespace log {
/// \brief Set Root Logger Name
///
-/// \param name Name of the root logger. This should be the program
-/// name.
-
+/// This function should be called by the program's initialization code before
+/// any logging functions are called.
+///
+/// \param name Name of the root logger. This should be the program name.
void setRootLoggerName(const std::string& name);
+
+/// \brief Get Root Logger Name
+///
+/// \return Name of the root logger.
const std::string& getRootLoggerName();
}
diff --git a/src/lib/log/strutil.cc b/src/lib/log/strutil.cc
index dc755bc..8ed6c27 100644
--- a/src/lib/log/strutil.cc
+++ b/src/lib/log/strutil.cc
@@ -13,7 +13,6 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <numeric>
-#include <iostream>
#include <string.h>
#include <strutil.h>
diff --git a/src/lib/log/tests/logger_support_test.cc b/src/lib/log/tests/logger_support_test.cc
index 29ea440..4d8863e 100644
--- a/src/lib/log/tests/logger_support_test.cc
+++ b/src/lib/log/tests/logger_support_test.cc
@@ -31,9 +31,8 @@
using namespace isc::log;
-// Declare root logger and a loggers to use an example.
+// Declare logger to use an example.
Logger logger_ex("example");
-Logger logger_dlm("dlm");
// The program is invoked:
//
@@ -48,10 +47,11 @@ Logger logger_dlm("dlm");
int main(int argc, char** argv) {
- isc::log::Severity severity = isc::log::INFO;
- int dbglevel = -1;
- const char* localfile = NULL;
- int option;
+ isc::log::Severity severity = isc::log::INFO; // Default logger severity
+ int dbglevel = -1; // Logger debug level
+ const char* localfile = NULL; // Local message file
+ int option; // For getopt() processing
+ Logger logger_dlm("dlm", true); // Another example logger
// Parse options
while ((option = getopt(argc, argv, "s:d:")) != -1) {
@@ -89,7 +89,7 @@ int main(int argc, char** argv) {
}
// Update the logging parameters
- init("alpha", severity, dbglevel, localfile);
+ initLogger("alpha", severity, dbglevel, localfile);
// Log a few messages
logger_ex.fatal(MSG_MSGWRTERR, "test1", "42");
More information about the bind10-changes
mailing list