Parcourir la source

[trac558] Make messages more message-compiler/logger specific

Replaced some of the more general message IDs (such as OPENIN or
RDERR) with ones more specific to the message compiler and logging
code.  The general ones were too general given that the ID has to
be totally unique within BIND10.
Stephen Morris il y a 14 ans
Parent
commit
3c66bce7b2

+ 4 - 4
src/lib/log/compiler/message.cc

@@ -266,7 +266,7 @@ writeHeaderFile(const string& file, const string& prefix,
 
     try {
         if (hfile.fail()) {
-            throw MessageException(MSG_OPENOUT, header_file.fullName(),
+            throw MessageException(MSG_OPNMSGOUT, header_file.fullName(),
                 strerror(errno));
         }
 
@@ -300,7 +300,7 @@ writeHeaderFile(const string& file, const string& prefix,
 
         // Report errors (if any) and exit
         if (hfile.fail()) {
-            throw MessageException(MSG_WRITERR, header_file.fullName(),
+            throw MessageException(MSG_MSGWRTERR, header_file.fullName(),
                 strerror(errno));
         }
 
@@ -340,7 +340,7 @@ writeProgramFile(const string& file, const string& prefix,
     ofstream ccfile(program_file.fullName().c_str());
     try {
         if (ccfile.fail()) {
-            throw MessageException(MSG_OPENOUT, program_file.fullName(),
+            throw MessageException(MSG_OPNMSGOUT, program_file.fullName(),
                 strerror(errno));
         }
 
@@ -399,7 +399,7 @@ writeProgramFile(const string& file, const string& prefix,
  
         // Report errors (if any) and exit
         if (ccfile.fail()) {
-            throw MessageException(MSG_WRITERR, program_file.fullName(),
+            throw MessageException(MSG_MSGWRTERR, program_file.fullName(),
                 strerror(errno));
         }
 

+ 4 - 4
src/lib/log/message_reader.cc

@@ -45,7 +45,7 @@ MessageReader::readFile(const string& file, MessageReader::Mode mode) {
     // Open the file
     ifstream infile(file.c_str());
     if (infile.fail()) {
-        throw MessageException(MSG_OPENIN, file, strerror(errno));
+        throw MessageException(MSG_OPNMSGIN, file, strerror(errno));
     }
 
     // Loop round reading it.
@@ -58,7 +58,7 @@ MessageReader::readFile(const string& file, MessageReader::Mode mode) {
 
     // Why did the loop terminate?
     if (!infile.eof()) {
-        throw MessageException(MSG_READERR, file, strerror(errno));
+        throw MessageException(MSG_MSGRDERR, file, strerror(errno));
     }
     infile.close();
 }
@@ -199,7 +199,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
     if (first_delim == string::npos) {
 
         // Just a single token in the line - this is not valid
-        throw MessageException(MSG_ONETOKEN, text);
+        throw MessageException(MSG_NOMSGTXT, text);
     }
 
     // Extract the first token into the message ID
@@ -212,7 +212,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
         // ?? This happens if there are trailing delimiters, which should not
         // occur as we have stripped trailing spaces off the line.  Just treat
         // this as a single-token error for simplicity's sake.
-        throw MessageException(MSG_ONETOKEN, text);
+        throw MessageException(MSG_NOMSGTXT, text);
     }
 
     // Add the result to the dictionary and to the non-added list if the add to

+ 12 - 12
src/lib/log/messagedef.cc

@@ -1,4 +1,4 @@
-// File created from messagedef.mes on Wed Feb  9 13:09:05 2011
+// File created from messagedef.mes on Wed Feb  9 16:55:11 2011
 
 #include <cstddef>
 #include <log/message_types.h>
@@ -11,19 +11,19 @@ extern const isc::log::MessageID MSG_DUPLNS = "DUPLNS";
 extern const isc::log::MessageID MSG_DUPLPRFX = "DUPLPRFX";
 extern const isc::log::MessageID MSG_DUPMSGID = "DUPMSGID";
 extern const isc::log::MessageID MSG_IDNOTFND = "IDNOTFND";
+extern const isc::log::MessageID MSG_MSGRDERR = "MSGRDERR";
+extern const isc::log::MessageID MSG_MSGWRTERR = "MSGWRTERR";
+extern const isc::log::MessageID MSG_NOMSGTXT = "NOMSGTXT";
 extern const isc::log::MessageID MSG_NSEXTRARG = "NSEXTRARG";
 extern const isc::log::MessageID MSG_NSINVARG = "NSINVARG";
 extern const isc::log::MessageID MSG_NSNOARG = "NSNOARG";
-extern const isc::log::MessageID MSG_ONETOKEN = "ONETOKEN";
-extern const isc::log::MessageID MSG_OPENIN = "OPENIN";
-extern const isc::log::MessageID MSG_OPENOUT = "OPENOUT";
+extern const isc::log::MessageID MSG_OPNMSGIN = "OPNMSGIN";
+extern const isc::log::MessageID MSG_OPNMSGOUT = "OPNMSGOUT";
 extern const isc::log::MessageID MSG_PRFEXTRARG = "PRFEXTRARG";
 extern const isc::log::MessageID MSG_PRFINVARG = "PRFINVARG";
 extern const isc::log::MessageID MSG_PRFNOARG = "PRFNOARG";
 extern const isc::log::MessageID MSG_RDLOCMES = "RDLOCMES";
-extern const isc::log::MessageID MSG_READERR = "READERR";
 extern const isc::log::MessageID MSG_UNRECDIR = "UNRECDIR";
-extern const isc::log::MessageID MSG_WRITERR = "WRITERR";
 
 } // namespace log
 } // namespace isc
@@ -33,21 +33,21 @@ namespace {
 const char* values[] = {
     "DUPLNS", "duplicate $NAMESPACE directive found",
     "DUPLPRFX", "duplicate $PREFIX directive found",
-    "DUPMSGID", "duplicate ID found in source code: %s",
+    "DUPMSGID", "duplicate message ID (%s) in compiled code",
     "IDNOTFND", "could not replace message for '%s': no such message identification",
+    "MSGRDERR", "error reading from message file %s: %s",
+    "MSGWRTERR", "error writing to %s: %s",
+    "NOMSGTXT", "a line containing a message ID ('%s') and nothing else was found",
     "NSEXTRARG", "$NAMESPACE directive has too many arguments",
     "NSINVARG", "$NAMESPACE directive has an invalid argument ('%s')",
     "NSNOARG", "no arguments were given to the $NAMESPACE directive",
-    "ONETOKEN", "a line containing a message ID ('%s') and nothing else was found",
-    "OPENIN", "unable to open message file %s for input: %s",
-    "OPENOUT", "unable to open %s for output: %s",
+    "OPNMSGIN", "unable to open message file %s for input: %s",
+    "OPNMSGOUT", "unable to open %s for output: %s",
     "PRFEXTRARG", "$PREFIX directive has too many arguments",
     "PRFINVARG", "$PREFIX directive has an invalid argument ('%s')",
     "PRFNOARG", "no arguments were given to the $PREFIX directive",
     "RDLOCMES", "reading local message file %s",
-    "READERR", "error reading from %s: %s",
     "UNRECDIR", "unrecognised directive '%s'",
-    "WRITERR", "error writing to %s: %s",
     NULL
 };
 

+ 6 - 6
src/lib/log/messagedef.h

@@ -1,4 +1,4 @@
-// File created from messagedef.mes on Wed Feb  9 13:09:05 2011
+// File created from messagedef.mes on Wed Feb  9 16:55:11 2011
 
 #ifndef __MESSAGEDEF_H
 #define __MESSAGEDEF_H
@@ -12,19 +12,19 @@ extern const isc::log::MessageID MSG_DUPLNS;
 extern const isc::log::MessageID MSG_DUPLPRFX;
 extern const isc::log::MessageID MSG_DUPMSGID;
 extern const isc::log::MessageID MSG_IDNOTFND;
+extern const isc::log::MessageID MSG_MSGRDERR;
+extern const isc::log::MessageID MSG_MSGWRTERR;
+extern const isc::log::MessageID MSG_NOMSGTXT;
 extern const isc::log::MessageID MSG_NSEXTRARG;
 extern const isc::log::MessageID MSG_NSINVARG;
 extern const isc::log::MessageID MSG_NSNOARG;
-extern const isc::log::MessageID MSG_ONETOKEN;
-extern const isc::log::MessageID MSG_OPENIN;
-extern const isc::log::MessageID MSG_OPENOUT;
+extern const isc::log::MessageID MSG_OPNMSGIN;
+extern const isc::log::MessageID MSG_OPNMSGOUT;
 extern const isc::log::MessageID MSG_PRFEXTRARG;
 extern const isc::log::MessageID MSG_PRFINVARG;
 extern const isc::log::MessageID MSG_PRFNOARG;
 extern const isc::log::MessageID MSG_RDLOCMES;
-extern const isc::log::MessageID MSG_READERR;
 extern const isc::log::MessageID MSG_UNRECDIR;
-extern const isc::log::MessageID MSG_WRITERR;
 
 } // namespace log
 } // namespace isc

+ 30 - 24
src/lib/log/messagedef.mes

@@ -23,12 +23,16 @@ $NAMESPACE isc::log
 # chicken-and-egg situation where we need the files to build the message
 # compiler, yet we need the compiler to build the files.
 
-DUPMSGID  duplicate ID found in source code: %s
-+ The same message identification appears in more that one file in the BIND10
-+ source code.  Every message logged by BIND10 should have a unique
-+ identification associated with it, so this indicates a failure in the build
-+ process.  The develops should locate the duplicate IDs and alter one (or more)
-+ of them.
+DUPMSGID  duplicate message ID (%s) in compiled code
++ Indicative of a programming error, when it started up, BIND10 detected that
++ the given message ID had been registered by one or more modules.  (All message
++ IDs should be unique throughout BIND10.)  This has no impact on the operation
++ of the server other that erroneous messages may be logged.  (When BIND10 loads
++ the message IDs (and their associated text), if a duplicate ID is found it is
++ discarded.  However, when the module that supplied the duplicate ID logs that
++ particular message, the text supplied by the module that added the original
++ ID will be output - something that may bear no relation to the condition being
++ logged.
 
 DUPLNS    duplicate $NAMESPACE directive found
 + When reading a message file, more than one $NAMESPACE directive was found.  In
@@ -51,33 +55,40 @@ IDNOTFND    could not replace message for '%s': no such message identification
 + This message may appear a number of times in the file, once for every such
 + unknown mnessage identification.
 
+MSGRDERR    error reading from message file %s: %s
++ The specified error was encountered reading from the named message file.
+
+MSGWRTERR   error writing to %s: %s
++ The specified error was encountered by the message compiler when writing to
++ the named output file.
+
 NSEXTRARG  $NAMESPACE directive has too many arguments
 + The $NAMESPACE directive takes a single argument, a namespace in which all the
 + generated symbol names are placed.  This error is generated when the
 + compiler finds a $NAMESPACE directive with more than one argument.
 
-NSINVARG   $NAMESPACE directive has an invalid argument ('%s')
+NSINVARG    $NAMESPACE directive has an invalid argument ('%s')
 + The $NAMESPACE argument should be a valid C++ namespace.  The reader does a
 + cursory check on its validity, checking that the characters in the namspace
 + are correct.  The error is generated when the reader finds an invalid
 + character. (Valid are alphanumeric characters, underscroes and colons.)
 
-NSNOARG    no arguments were given to the $NAMESPACE directive
-+ The $NAMESPACE directive takes a single argument, a namespace in which all the
-+ generated symbol names are placed.  This error is generated when the
-+ compiler finds a $NAMESPACE directive with no arguments.
-
-ONETOKEN    a line containing a message ID ('%s') and nothing else was found
+NOMSGTXT    a line containing a message ID ('%s') and nothing else was found
 + Message definitions comprise lines starting with a message identification (a
 + symbolic name for the message) and followed by the text of the message.  This
 + error is generated when a line is found in the message file that contains just
-+ the message identification.
++ the message identification and no text.
 
-OPENIN      unable to open message file %s for input: %s
+NSNOARG     no arguments were given to the $NAMESPACE directive
++ The $NAMESPACE directive takes a single argument, a namespace in which all the
++ generated symbol names are placed.  This error is generated when the
++ compiler finds a $NAMESPACE directive with no arguments.
+
+OPNMSGIN     unable to open message file %s for input: %s
 + The program was not able to open the specified input message file for the
 + reason given.
 
-OPENOUT     unable to open %s for output: %s
+OPNMSGOUT   unable to open %s for output: %s
 + The program was not able to open the specified output file for the reason
 + given.
 
@@ -99,15 +110,10 @@ PRFNOARG    no arguments were given to the $PREFIX directive
 + compiler finds a $PREFIX directive with no arguments.
 
 RDLOCMES    reading local message file %s
-+ This is an informational message output on BIND start-up when it is about to
-+ read a supplied local message file.
-
-READERR     error reading from %s: %s
-+ The specified error was encountered reading from the named input file.
++ This is an informational message output by BIND10 when it starts to read a
++ local message file.  (A local message file may replace the text of one of more
++ messages; the ID of the message will not be changed though.)
 
 UNRECDIR    unrecognised directive '%s'
 + A line starting with a dollar symbol was found, but the first word on the line
 + (shown in the message) was not a recognised message compiler directive.
-
-WRITERR     error writing to %s: %s
-+ The specified error was encountered writing to the named output file.

+ 3 - 3
src/lib/log/tests/logger_support_test.cc

@@ -92,10 +92,10 @@ int main(int argc, char** argv) {
     init("alpha", severity, dbglevel, localfile);
 
     // Log a few messages
-    logger_ex.fatal(MSG_WRITERR, "test1", "42");
+    logger_ex.fatal(MSG_MSGWRTERR, "test1", "42");
     logger_ex.error(MSG_UNRECDIR, "false");
-    logger_dlm.warn(MSG_READERR, "a.txt", "dummy test");
-    logger_dlm.info(MSG_OPENIN, "example.msg", "dummy test");
+    logger_dlm.warn(MSG_MSGRDERR, "a.txt", "dummy test");
+    logger_dlm.info(MSG_OPNMSGIN, "example.msg", "dummy test");
     logger_ex.debug(0, MSG_UNRECDIR, "[abc]");
     logger_ex.debug(24, MSG_UNRECDIR, "[24]");
     logger_ex.debug(25, MSG_UNRECDIR, "[25]");

+ 10 - 10
src/lib/log/tests/run_time_init_test.sh.in

@@ -31,24 +31,24 @@ passfail() {
 
 cat > $localmes << .
 NOTHERE     this message is not in the global dictionary
-READERR     replacement read error, parameters: '%s' and '%s'
+MSGRDERR    replacement read error, parameters: '%s' and '%s'
 UNRECDIR    replacement unrecognised directive message, parameter is '%s'
 .
 
     
 echo -n "1. runInitTest default parameters: "
 cat > $tempfile << .
-FATAL [alpha.example] WRITERR, error writing to test1: 42
+FATAL [alpha.example] MSGWRTERR, error writing to test1: 42
 ERROR [alpha.example] UNRECDIR, unrecognised directive 'false'
-WARN  [alpha.dlm] READERR, error reading from a.txt: dummy test
-INFO  [alpha.dlm] OPENIN, unable to open message file example.msg for input: dummy test
+WARN  [alpha.dlm] MSGRDERR, error reading from message file a.txt: dummy test
+INFO  [alpha.dlm] OPNMSGIN, unable to open message file example.msg for input: dummy test
 .
 ./logger_support_test | cut -d' ' -f3- | diff $tempfile -
 passfail $?
 
 echo -n "2. Severity filter: "
 cat > $tempfile << .
-FATAL [alpha.example] WRITERR, error writing to test1: 42
+FATAL [alpha.example] MSGWRTERR, error writing to test1: 42
 ERROR [alpha.example] UNRECDIR, unrecognised directive 'false'
 .
 ./logger_support_test -s error | cut -d' ' -f3- | diff $tempfile -
@@ -56,10 +56,10 @@ passfail $?
 
 echo -n "3. Debug level: "
 cat > $tempfile << .
-FATAL [alpha.example] WRITERR, error writing to test1: 42
+FATAL [alpha.example] MSGWRTERR, error writing to test1: 42
 ERROR [alpha.example] UNRECDIR, unrecognised directive 'false'
-WARN  [alpha.dlm] READERR, error reading from a.txt: dummy test
-INFO  [alpha.dlm] OPENIN, unable to open message file example.msg for input: dummy test
+WARN  [alpha.dlm] MSGRDERR, error reading from message file a.txt: dummy test
+INFO  [alpha.dlm] OPNMSGIN, unable to open message file example.msg for input: dummy test
 DEBUG [alpha.example] UNRECDIR, unrecognised directive '[abc]'
 DEBUG [alpha.example] UNRECDIR, unrecognised directive '[24]'
 DEBUG [alpha.example] UNRECDIR, unrecognised directive '[25]'
@@ -70,9 +70,9 @@ passfail $?
 echo -n "4. Local message replacement: "
 cat > $tempfile << .
 WARN  [alpha.log] IDNOTFND, could not replace message for 'NOTHERE': no such message identification
-FATAL [alpha.example] WRITERR, error writing to test1: 42
+FATAL [alpha.example] MSGWRTERR, error writing to test1: 42
 ERROR [alpha.example] UNRECDIR, replacement unrecognised directive message, parameter is 'false'
-WARN  [alpha.dlm] READERR, replacement read error, parameters: 'a.txt' and 'dummy test'
+WARN  [alpha.dlm] MSGRDERR, replacement read error, parameters: 'a.txt' and 'dummy test'
 .
 ./logger_support_test -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
 passfail $?