Commit e560672e authored by Stephen Morris's avatar Stephen Morris
Browse files

[trac1040] Expand message IDs into words separated by underscores

Also change prefix from MSG_ (which is not specific) to LOG_ (which
identifies the messages as part of the logging code).
parent ebc9aa4d
......@@ -306,7 +306,7 @@ writeHeaderFile(const string& file, const vector<string>& ns_components,
ofstream hfile(header_file.fullName().c_str());
if (hfile.fail()) {
throw MessageException(MSG_OPENOUT, header_file.fullName(),
throw MessageException(LOG_OPEN_OUTPUT_FAIL, header_file.fullName(),
strerror(errno));
}
......@@ -340,7 +340,7 @@ writeHeaderFile(const string& file, const vector<string>& ns_components,
// Report errors (if any) and exit
if (hfile.fail()) {
throw MessageException(MSG_WRITERR, header_file.fullName(),
throw MessageException(LOG_WRITE_ERROR, header_file.fullName(),
strerror(errno));
}
......@@ -394,7 +394,7 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
ofstream ccfile(program_file.fullName().c_str());
if (ccfile.fail()) {
throw MessageException(MSG_OPENOUT, program_file.fullName(),
throw MessageException(LOG_OPEN_OUTPUT_FAIL, program_file.fullName(),
strerror(errno));
}
......@@ -452,7 +452,7 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
// Report errors (if any) and exit
if (ccfile.fail()) {
throw MessageException(MSG_WRITERR, program_file.fullName(),
throw MessageException(LOG_WRITE_ERROR, program_file.fullName(),
strerror(errno));
}
......
......@@ -7,26 +7,26 @@
namespace isc {
namespace log {
extern const isc::log::MessageID MSG_BADDESTINATION = "MSG_BADDESTINATION";
extern const isc::log::MessageID MSG_BADSEVERITY = "MSG_BADSEVERITY";
extern const isc::log::MessageID MSG_BADSTREAM = "MSG_BADSTREAM";
extern const isc::log::MessageID MSG_DUPLNS = "MSG_DUPLNS";
extern const isc::log::MessageID MSG_DUPMSGID = "MSG_DUPMSGID";
extern const isc::log::MessageID MSG_IDNOTFND = "MSG_IDNOTFND";
extern const isc::log::MessageID MSG_INVMSGID = "MSG_INVMSGID";
extern const isc::log::MessageID MSG_NOMSGID = "MSG_NOMSGID";
extern const isc::log::MessageID MSG_NOMSGTXT = "MSG_NOMSGTXT";
extern const isc::log::MessageID MSG_NSEXTRARG = "MSG_NSEXTRARG";
extern const isc::log::MessageID MSG_NSINVARG = "MSG_NSINVARG";
extern const isc::log::MessageID MSG_NSNOARG = "MSG_NSNOARG";
extern const isc::log::MessageID MSG_OPENIN = "MSG_OPENIN";
extern const isc::log::MessageID MSG_OPENOUT = "MSG_OPENOUT";
extern const isc::log::MessageID MSG_PRFEXTRARG = "MSG_PRFEXTRARG";
extern const isc::log::MessageID MSG_PRFINVARG = "MSG_PRFINVARG";
extern const isc::log::MessageID MSG_RDLOCMES = "MSG_RDLOCMES";
extern const isc::log::MessageID MSG_READERR = "MSG_READERR";
extern const isc::log::MessageID MSG_UNRECDIR = "MSG_UNRECDIR";
extern const isc::log::MessageID MSG_WRITERR = "MSG_WRITERR";
extern const isc::log::MessageID LOG_BAD_DESTINATION = "LOG_BAD_DESTINATION";
extern const isc::log::MessageID LOG_BAD_SEVERITY = "LOG_BAD_SEVERITY";
extern const isc::log::MessageID LOG_BAD_STREAM = "LOG_BAD_STREAM";
extern const isc::log::MessageID LOG_DUPLICATE_NAMESPACE = "LOG_DUPLICATE_NAMESPACE";
extern const isc::log::MessageID LOG_DUPLICATE_MESSAGE_ID = "LOG_DUPLICATE_MESSAGE_ID";
extern const isc::log::MessageID LOG_NO_SUCH_MESSAGE = "LOG_NO_SUCH_MESSAGE";
extern const isc::log::MessageID LOG_INVALID_MESSAGE_ID = "LOG_INVALID_MESSAGE_ID";
extern const isc::log::MessageID LOG_NO_MESSAGE_ID = "LOG_NO_MESSAGE_ID";
extern const isc::log::MessageID LOG_NO_MESSAGE_TEXT = "LOG_NO_MESSAGE_TEXT";
extern const isc::log::MessageID LOG_NAMESPACE_EXTRA_ARGS = "LOG_NAMESPACE_EXTRA_ARGS";
extern const isc::log::MessageID LOG_NAMESPACE_INVALID_ARG = "LOG_NAMESPACE_INVALID_ARG";
extern const isc::log::MessageID LOG_NAMESPACE_NO_ARGS = "LOG_NAMESPACE_NO_ARGS";
extern const isc::log::MessageID LOG_INPUT_OPEN_FAIL = "LOG_INPUT_OPEN_FAIL";
extern const isc::log::MessageID LOG_OPEN_OUTPUT_FAIL = "LOG_OPEN_OUTPUT_FAIL";
extern const isc::log::MessageID LOG_PREFIX_EXTRA_ARGS = "LOG_PREFIX_EXTRA_ARGS";
extern const isc::log::MessageID LOG_PREFIX_INVALID_ARG = "LOG_PREFIX_INVALID_ARG";
extern const isc::log::MessageID LOG_READING_LOCAL_FILE = "LOG_READING_LOCAL_FILE";
extern const isc::log::MessageID LOG_READ_ERROR = "LOG_READ_ERROR";
extern const isc::log::MessageID LOG_UNRECOGNISED_DIRECTIVE = "LOG_UNRECOGNISED_DIRECTIVE";
extern const isc::log::MessageID LOG_WRITE_ERROR = "LOG_WRITE_ERROR";
} // namespace log
} // namespace isc
......@@ -34,26 +34,26 @@ extern const isc::log::MessageID MSG_WRITERR = "MSG_WRITERR";
namespace {
const char* values[] = {
"MSG_BADDESTINATION", "unrecognized log destination: %1",
"MSG_BADSEVERITY", "unrecognized log severity: %1",
"MSG_BADSTREAM", "bad log console output stream: %1",
"MSG_DUPLNS", "line %1: duplicate $NAMESPACE directive found",
"MSG_DUPMSGID", "duplicate message ID (%1) in compiled code",
"MSG_IDNOTFND", "could not replace message text for '%1': no such message",
"MSG_INVMSGID", "line %1: invalid message identification '%2'",
"MSG_NOMSGID", "line %1: message definition line found without a message ID",
"MSG_NOMSGTXT", "line %1: line found containing a message ID ('%2') and no text",
"MSG_NSEXTRARG", "line %1: $NAMESPACE directive has too many arguments",
"MSG_NSINVARG", "line %1: $NAMESPACE directive has an invalid argument ('%2')",
"MSG_NSNOARG", "line %1: no arguments were given to the $NAMESPACE directive",
"MSG_OPENIN", "unable to open message file %1 for input: %2",
"MSG_OPENOUT", "unable to open %1 for output: %2",
"MSG_PRFEXTRARG", "line %1: $PREFIX directive has too many arguments",
"MSG_PRFINVARG", "line %1: $PREFIX directive has an invalid argument ('%2')",
"MSG_RDLOCMES", "reading local message file %1",
"MSG_READERR", "error reading from message file %1: %2",
"MSG_UNRECDIR", "line %1: unrecognised directive '%2'",
"MSG_WRITERR", "error writing to %1: %2",
"LOG_BAD_DESTINATION", "unrecognized log destination: %1",
"LOG_BAD_SEVERITY", "unrecognized log severity: %1",
"LOG_BAD_STREAM", "bad log console output stream: %1",
"LOG_DUPLICATE_NAMESPACE", "line %1: duplicate $NAMESPACE directive found",
"LOG_DUPLICATE_MESSAGE_ID", "duplicate message ID (%1) in compiled code",
"LOG_NO_SUCH_MESSAGE", "could not replace message text for '%1': no such message",
"LOG_INVALID_MESSAGE_ID", "line %1: invalid message identification '%2'",
"LOG_NO_MESSAGE_ID", "line %1: message definition line found without a message ID",
"LOG_NO_MESSAGE_TEXT", "line %1: line found containing a message ID ('%2') and no text",
"LOG_NAMESPACE_EXTRA_ARGS", "line %1: $NAMESPACE directive has too many arguments",
"LOG_NAMESPACE_INVALID_ARG", "line %1: $NAMESPACE directive has an invalid argument ('%2')",
"LOG_NAMESPACE_NO_ARGS", "line %1: no arguments were given to the $NAMESPACE directive",
"LOG_INPUT_OPEN_FAIL", "unable to open message file %1 for input: %2",
"LOG_OPEN_OUTPUT_FAIL", "unable to open %1 for output: %2",
"LOG_PREFIX_EXTRA_ARGS", "line %1: $PREFIX directive has too many arguments",
"LOG_PREFIX_INVALID_ARG", "line %1: $PREFIX directive has an invalid argument ('%2')",
"LOG_READING_LOCAL_FILE", "reading local message file %1",
"LOG_READ_ERROR", "error reading from message file %1: %2",
"LOG_UNRECOGNISED_DIRECTIVE", "line %1: unrecognised directive '%2'",
"LOG_WRITE_ERROR", "error writing to %1: %2",
NULL
};
......
......@@ -8,26 +8,26 @@
namespace isc {
namespace log {
extern const isc::log::MessageID MSG_BADDESTINATION;
extern const isc::log::MessageID MSG_BADSEVERITY;
extern const isc::log::MessageID MSG_BADSTREAM;
extern const isc::log::MessageID MSG_DUPLNS;
extern const isc::log::MessageID MSG_DUPMSGID;
extern const isc::log::MessageID MSG_IDNOTFND;
extern const isc::log::MessageID MSG_INVMSGID;
extern const isc::log::MessageID MSG_NOMSGID;
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_OPENIN;
extern const isc::log::MessageID MSG_OPENOUT;
extern const isc::log::MessageID MSG_PRFEXTRARG;
extern const isc::log::MessageID MSG_PRFINVARG;
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;
extern const isc::log::MessageID LOG_BAD_DESTINATION;
extern const isc::log::MessageID LOG_BAD_SEVERITY;
extern const isc::log::MessageID LOG_BAD_STREAM;
extern const isc::log::MessageID LOG_DUPLICATE_NAMESPACE;
extern const isc::log::MessageID LOG_DUPLICATE_MESSAGE_ID;
extern const isc::log::MessageID LOG_NO_SUCH_MESSAGE;
extern const isc::log::MessageID LOG_INVALID_MESSAGE_ID;
extern const isc::log::MessageID LOG_NO_MESSAGE_ID;
extern const isc::log::MessageID LOG_NO_MESSAGE_TEXT;
extern const isc::log::MessageID LOG_NAMESPACE_EXTRA_ARGS;
extern const isc::log::MessageID LOG_NAMESPACE_INVALID_ARG;
extern const isc::log::MessageID LOG_NAMESPACE_NO_ARGS;
extern const isc::log::MessageID LOG_INPUT_OPEN_FAIL;
extern const isc::log::MessageID LOG_OPEN_OUTPUT_FAIL;
extern const isc::log::MessageID LOG_PREFIX_EXTRA_ARGS;
extern const isc::log::MessageID LOG_PREFIX_INVALID_ARG;
extern const isc::log::MessageID LOG_READING_LOCAL_FILE;
extern const isc::log::MessageID LOG_READ_ERROR;
extern const isc::log::MessageID LOG_UNRECOGNISED_DIRECTIVE;
extern const isc::log::MessageID LOG_WRITE_ERROR;
} // namespace log
} // namespace isc
......
......@@ -22,7 +22,7 @@
$NAMESPACE isc::log
% MSG_DUPMSGID duplicate message ID (%1) in compiled code
% LOG_DUPLICATE_MESSAGE_ID duplicate message ID (%1) 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
......@@ -33,12 +33,12 @@ 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.
% MSG_DUPLNS line %1: duplicate $NAMESPACE directive found
% LOG_DUPLICATE_NAMESPACE line %1: duplicate $NAMESPACE directive found
When reading a message file, more than one $NAMESPACE directive was found. In
this version of the code, such a condition is regarded as an error and the
read will be abandoned.
% MSG_IDNOTFND could not replace message text for '%1': no such message
% LOG_NO_SUCH_MESSAGE could not replace message text for '%1': no such message
During start-up a local message file was read. A line with the listed
message identification was found in the file, but the identification is not
one contained in the compiled-in message dictionary. Either the message
......@@ -49,82 +49,82 @@ identification has been removed.
This message may appear a number of times in the file, once for every such
unknown message identification.
% MSG_INVMSGID line %1: invalid message identification '%2'
% LOG_INVALID_MESSAGE_ID line %1: invalid message identification '%2'
The concatenation of the prefix and the message identification is used as
a symbol in the C++ module; as such it may only contain
% MSG_NOMSGID line %1: message definition line found without a message ID
% LOG_NO_MESSAGE_ID line %1: message definition line found without a message ID
Message definition lines are lines starting with a "%". The rest of the line
should comprise the message ID and text describing the message. This error
indicates the message compiler found a line in the message file comprising
just the "%" and nothing else.
% MSG_NOMSGTXT line %1: line found containing a message ID ('%2') and no text
% LOG_NO_MESSAGE_TEXT line %1: line found containing a message ID ('%2') and no text
Message definition lines are lines starting with a "%". The rest of the line
should comprise the message ID and text describing the message. This error
is generated when a line is found in the message file that contains the
leading "%" and the message identification but no text.
% MSG_NSEXTRARG line %1: $NAMESPACE directive has too many arguments
% LOG_NAMESPACE_EXTRA_ARGS line %1: $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.
% MSG_NSINVARG line %1: $NAMESPACE directive has an invalid argument ('%2')
% LOG_NAMESPACE_INVALID_ARG line %1: $NAMESPACE directive has an invalid argument ('%2')
The $NAMESPACE argument should be a valid C++ namespace. The reader does a
cursory check on its validity, checking that the characters in the namespace
are correct. The error is generated when the reader finds an invalid
character. (Valid are alphanumeric characters, underscores and colons.)
% MSG_NSNOARG line %1: no arguments were given to the $NAMESPACE directive
% LOG_NAMESPACE_NO_ARGS line %1: 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.
% MSG_OPENIN unable to open message file %1 for input: %2
% LOG_INPUT_OPEN_FAIL unable to open message file %1 for input: %2
The program was not able to open the specified input message file for the
reason given.
% MSG_OPENOUT unable to open %1 for output: %2
% LOG_OPEN_OUTPUT_FAIL unable to open %1 for output: %2
The program was not able to open the specified output file for the reason
given.
% MSG_PRFEXTRARG line %1: $PREFIX directive has too many arguments
% LOG_PREFIX_EXTRA_ARGS line %1: $PREFIX directive has too many arguments
The $PREFIX directive takes a single argument, a prefix to be added to the
symbol names when a C++ .h file is created. This error is generated when the
compiler finds a $PREFIX directive with more than one argument.
% MSG_PRFINVARG line %1: $PREFIX directive has an invalid argument ('%2')
% LOG_PREFIX_INVALID_ARG line %1: $PREFIX directive has an invalid argument ('%2')
The $PREFIX argument is used in a symbol name in a C++ header file. As such,
it must adhere to restrictions on C++ symbol names (e.g. may only contain
alphanumeric characters or underscores, and may nor start with a digit).
A $PREFIX directive was found with an argument (given in the message) that
violates those restictions.
% MSG_RDLOCMES reading local message file %1
% LOG_READING_LOCAL_FILE reading local message file %1
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.)
% MSG_READERR error reading from message file %1: %2
% LOG_READ_ERROR error reading from message file %1: %2
The specified error was encountered reading from the named message file.
% MSG_WRITERR error writing to %1: %2
% LOG_WRITE_ERROR error writing to %1: %2
The specified error was encountered by the message compiler when writing to
the named output file.
% MSG_UNRECDIR line %1: unrecognised directive '%2'
% LOG_UNRECOGNISED_DIRECTIVE line %1: unrecognised directive '%2'
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.
% MSG_BADSEVERITY unrecognized log severity: %1
% LOG_BAD_SEVERITY unrecognized log severity: %1
A logger severity value was given that was not recognized. The severity
should be one of "DEBUG", "INFO", "WARN", "ERROR", or "FATAL".
% MSG_BADDESTINATION unrecognized log destination: %1
% LOG_BAD_DESTINATION unrecognized log destination: %1
A logger destination value was given that was not recognized. The
destination should be one of "console", "file", or "syslog".
% MSG_BADSTREAM bad log console output stream: %1
% LOG_BAD_STREAM bad log console output stream: %1
A log console output stream was given that was not recognized. The
output stream should be one of "stdout", or "stderr"
......@@ -38,7 +38,7 @@ getSeverity(const std::string& sev_str) {
return isc::log::NONE;
} else {
Logger logger("log");
LOG_ERROR(logger, MSG_BADSEVERITY).arg(sev_str);
LOG_ERROR(logger, LOG_BAD_SEVERITY).arg(sev_str);
return isc::log::INFO;
}
}
......
......@@ -122,7 +122,7 @@ LoggerManager::init(const std::string& root, isc::log::Severity severity,
sort(duplicates.begin(), duplicates.end());
for (vector<string>::iterator i = duplicates.begin();
i != duplicates.end(); ++i) {
LOG_WARN(logger, MSG_DUPMSGID).arg(*i);
LOG_WARN(logger, LOG_DUPLICATE_MESSAGE_ID).arg(*i);
}
}
......@@ -144,7 +144,7 @@ LoggerManager::readLocalMessageFile(const char* file) {
MessageReader reader(&dictionary);
try {
logger.info(MSG_RDLOCMES).arg(file);
logger.info(LOG_READING_LOCAL_FILE).arg(file);
reader.readFile(file, MessageReader::REPLACE);
// File successfully read. As each message in the file is supposed to
......@@ -155,7 +155,7 @@ LoggerManager::readLocalMessageFile(const char* file) {
for (MessageReader::MessageIDCollection::const_iterator
i = unknown.begin(); i != unknown.end(); ++i) {
string message_id = boost::lexical_cast<string>(*i);
logger.warn(MSG_IDNOTFND).arg(message_id);
logger.warn(LOG_NO_SUCH_MESSAGE).arg(message_id);
}
}
catch (MessageException& e) {
......
......@@ -48,7 +48,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(LOG_INPUT_OPEN_FAIL, file, strerror(errno));
}
// Loop round reading it. As we process the file one line at a time,
......@@ -65,7 +65,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(LOG_READ_ERROR, file, strerror(errno));
}
infile.close();
}
......@@ -114,7 +114,7 @@ MessageReader::parseDirective(const std::string& text) {
} else {
// Unrecognised directive
throw MessageException(MSG_UNRECDIR, tokens[0], lineno_);
throw MessageException(LOG_UNRECOGNISED_DIRECTIVE, tokens[0], lineno_);
}
}
......@@ -138,13 +138,13 @@ MessageReader::parsePrefix(const vector<string>& tokens) {
// and numeric characters (and underscores) and does not start with a
// digit.
if (invalidSymbol(prefix_)) {
throw MessageException(MSG_PRFINVARG, prefix_, lineno_);
throw MessageException(LOG_PREFIX_INVALID_ARG, prefix_, lineno_);
}
} else {
// Too many arguments
throw MessageException(MSG_PRFEXTRARG, lineno_);
throw MessageException(LOG_PREFIX_EXTRA_ARGS, lineno_);
}
}
......@@ -172,10 +172,10 @@ MessageReader::parseNamespace(const vector<string>& tokens) {
// Check argument count
if (tokens.size() < 2) {
throw MessageException(MSG_NSNOARG, lineno_);
throw MessageException(LOG_NAMESPACE_NO_ARGS, lineno_);
} else if (tokens.size() > 2) {
throw MessageException(MSG_NSEXTRARG, lineno_);
throw MessageException(LOG_NAMESPACE_EXTRA_ARGS, lineno_);
}
......@@ -187,12 +187,12 @@ MessageReader::parseNamespace(const vector<string>& tokens) {
"abcdefghijklmnopqrstuvwxyz"
"0123456789_:";
if (tokens[1].find_first_not_of(valid_chars) != string::npos) {
throw MessageException(MSG_NSINVARG, tokens[1], lineno_);
throw MessageException(LOG_NAMESPACE_INVALID_ARG, tokens[1], lineno_);
}
// All OK - unless the namespace has already been set.
if (ns_.size() != 0) {
throw MessageException(MSG_DUPLNS, lineno_);
throw MessageException(LOG_DUPLICATE_NAMESPACE, lineno_);
}
// Prefix has not been set, so set it and return success.
......@@ -219,7 +219,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
// A line comprising just the message introducer is not valid.
if (text.size() == 1) {
throw MessageException(MSG_NOMSGID, text, lineno_);
throw MessageException(LOG_NO_MESSAGE_ID, text, lineno_);
}
// Strip off the introducer and any leading space after that.
......@@ -230,7 +230,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_NOMSGTXT, message_line, lineno_);
throw MessageException(LOG_NO_MESSAGE_TEXT, message_line, lineno_);
}
// Extract the first token into the message ID, preceding it with the
......@@ -240,7 +240,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
string ident = prefix_ + message_line.substr(0, first_delim);
if (prefix_.empty()) {
if (invalidSymbol(ident)) {
throw MessageException(MSG_INVMSGID, ident, lineno_);
throw MessageException(LOG_INVALID_MESSAGE_ID, ident, lineno_);
}
}
isc::util::str::uppercase(ident);
......@@ -252,7 +252,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_NOMSGTXT, message_line, lineno_);
throw MessageException(LOG_NO_MESSAGE_TEXT, message_line, lineno_);
}
// Add the result to the dictionary and to the non-added list if the add to
......
......@@ -33,7 +33,7 @@ getDestination(const std::string& dest_str) {
return OutputOption::DEST_SYSLOG;
} else {
Logger logger("log");
LOG_ERROR(logger, MSG_BADDESTINATION).arg(dest_str);
LOG_ERROR(logger, LOG_BAD_DESTINATION).arg(dest_str);
return OutputOption::DEST_CONSOLE;
}
}
......@@ -46,7 +46,7 @@ getStream(const std::string& stream_str) {
return OutputOption::STR_STDOUT;
} else {
Logger logger("log");
LOG_ERROR(logger, MSG_BADSTREAM).arg(stream_str);
LOG_ERROR(logger, LOG_BAD_STREAM).arg(stream_str);
return OutputOption::STR_STDOUT;
}
}
......
......@@ -37,10 +37,10 @@ passfail() {
echo "1. One logger, multiple destinations:"
cat > $tempfile << .
FATAL [example] MSG_WRITERR, error writing to test1: 42
ERROR [example] MSG_RDLOCMES, reading local message file dummy/file
FATAL [example.beta] MSG_BADSEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] MSG_BADDESTINATION, unrecognized log destination: beta_error
FATAL [example] LOG_WRITE_ERROR, error writing to test1: 42
ERROR [example] LOG_READING_LOCAL_FILE, reading local message file dummy/file
FATAL [example.beta] LOG_BAD_SEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] LOG_BAD_DESTINATION, unrecognized log destination: beta_error
.
rm -f $destfile1 $destfile2
./logger_example -s error -f $destfile1 -f $destfile2
......@@ -61,13 +61,13 @@ rm -f $destfile1 $destfile2
# Output for example.alpha should have done to destfile2.
cat > $tempfile << .
FATAL [example] MSG_WRITERR, error writing to test1: 42
ERROR [example] MSG_RDLOCMES, reading local message file dummy/file
WARN [example] MSG_BADSTREAM, bad log console output stream: example
FATAL [example.beta] MSG_BADSEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] MSG_BADDESTINATION, unrecognized log destination: beta_error
WARN [example.beta] MSG_BADSTREAM, bad log console output stream: beta_warn
INFO [example.beta] MSG_READERR, error reading from message file beta: info
FATAL [example] LOG_WRITE_ERROR, error writing to test1: 42
ERROR [example] LOG_READING_LOCAL_FILE, reading local message file dummy/file
WARN [example] LOG_BAD_STREAM, bad log console output stream: example
FATAL [example.beta] LOG_BAD_SEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] LOG_BAD_DESTINATION, unrecognized log destination: beta_error
WARN [example.beta] LOG_BAD_STREAM, bad log console output stream: beta_warn
INFO [example.beta] LOG_READ_ERROR, error reading from message file beta: info
.
echo -n " - destination 1:"
cut -d' ' -f3- $destfile1 | diff $tempfile -
......@@ -75,7 +75,7 @@ passfail $?
echo -n " - destination 2:"
cat > $tempfile << .
WARN [example.alpha] MSG_READERR, error reading from message file a.txt: dummy reason
WARN [example.alpha] LOG_READ_ERROR, error reading from message file a.txt: dummy reason
.
cut -d' ' -f3- $destfile2 | diff $tempfile -
passfail $?
......
......@@ -37,36 +37,35 @@ passfail() {
# Create the local message file for testing
cat > $localmes << .
\$PREFIX MSG_
% NOTHERE this message is not in the global dictionary
% READERR replacement read error, parameters: '%1' and '%2'
% RDLOCMES replacement read local message file, parameter is '%1'
% LOG_NOTHERE this message is not in the global dictionary
% LOG_READ_ERROR replacement read error, parameters: '%1' and '%2'
% LOG_READING_LOCAL_FILE replacement read local message file, parameter is '%1'
.
echo -n "1. Local message replacement:"
cat > $tempfile << .
WARN [example.log] MSG_IDNOTFND, could not replace message text for 'MSG_NOTHERE': no such message
FATAL [example] MSG_WRITERR, error writing to test1: 42
ERROR [example] MSG_RDLOCMES, replacement read local message file, parameter is 'dummy/file'
WARN [example] MSG_BADSTREAM, bad log console output stream: example
WARN [example.alpha] MSG_READERR, replacement read error, parameters: 'a.txt' and 'dummy reason'
FATAL [example.beta] MSG_BADSEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] MSG_BADDESTINATION, unrecognized log destination: beta_error
WARN [example.beta] MSG_BADSTREAM, bad log console output stream: beta_warn
WARN [example.log] LOG_NO_SUCH_MESSAGE, could not replace message text for 'LOG_NOTHERE': no such message
FATAL [example] LOG_WRITE_ERROR, error writing to test1: 42
ERROR [example] LOG_READING_LOCAL_FILE, replacement read local message file, parameter is 'dummy/file'
WARN [example] LOG_BAD_STREAM, bad log console output stream: example
WARN [example.alpha] LOG_READ_ERROR, replacement read error, parameters: 'a.txt' and 'dummy reason'
FATAL [example.beta] LOG_BAD_SEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] LOG_BAD_DESTINATION, unrecognized log destination: beta_error
WARN [example.beta] LOG_BAD_STREAM, bad log console output stream: beta_warn
.
./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
passfail $?
echo -n "2. Report error if unable to read local message file:"
cat > $tempfile << .
ERROR [example.log] MSG_OPENIN, unable to open message file $localmes for input: No such file or directory
FATAL [example] MSG_WRITERR, error writing to test1: 42
ERROR [example] MSG_RDLOCMES, reading local message file dummy/file
WARN [example] MSG_BADSTREAM, bad log console output stream: example
WARN [example.alpha] MSG_READERR, error reading from message file a.txt: dummy reason
FATAL [example.beta] MSG_BADSEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] MSG_BADDESTINATION, unrecognized log destination: beta_error
WARN [example.beta] MSG_BADSTREAM, bad log console output stream: beta_warn
ERROR [example.log] LOG_INPUT_OPEN_FAIL, unable to open message file $localmes for input: No such file or directory
FATAL [example] LOG_WRITE_ERROR, error writing to test1: 42
ERROR [example] LOG_READING_LOCAL_FILE, reading local message file dummy/file
WARN [example] LOG_BAD_STREAM, bad log console output stream: example
WARN [example.alpha] LOG_READ_ERROR, error reading from message file a.txt: dummy reason
FATAL [example.beta] LOG_BAD_SEVERITY, unrecognized log severity: beta_fatal
ERROR [example.beta] LOG_BAD_DESTINATION, unrecognized log destination: beta_error
WARN [example.beta] LOG_BAD_STREAM, bad log console output stream: beta_warn
.
rm -f $localmes
./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
......
......@@ -285,21 +285,21 @@ int main(int argc, char** argv) {
isc::log::Logger logger_alpha("alpha");
isc::log::Logger logger_beta("beta");
LOG_FATAL(logger_ex, MSG_WRITERR).arg("test1").arg("42");
LOG_ERROR(logger_ex, MSG_RDLOCMES).arg("dummy/file");
LOG_WARN(logger_ex, MSG_BADSTREAM).arg("example");
LOG_WARN(logger_alpha, MSG_READERR).arg("a.txt").arg("dummy reason");
LOG_INFO(logger_alpha, MSG_OPENIN).arg("example.msg").arg("dummy reason");
LOG_DEBUG(logger_ex, 0, MSG_RDLOCMES).arg("example/0");
LOG_DEBUG(logger_ex, 24, MSG_RDLOCMES).arg("example/24");
LOG_DEBUG(logger_ex, 25, MSG_RDLOCMES).arg("example/25");
LOG_DEBUG(logger_ex, 26, MSG_RDLOCMES).arg("example/26");
LOG_FATAL(logger_beta, MSG_BADSEVERITY).arg("beta_fatal");
LOG_ERROR(logger_beta, MSG_BADDESTINATION).arg("beta_error");
LOG_WARN(logger_beta, MSG_BADSTREAM).arg("beta_warn");
LOG_INFO(logger_beta, MSG_READERR).arg("beta").arg("info");
LOG_DEBUG(logger_beta, 25, MSG_BADSEVERITY).arg("beta/25");
LOG_DEBUG(logger_beta, 26, MSG_BADSEVERITY).arg("beta/26");
LOG_FATAL(logger_ex, LOG_WRITE_ERROR).arg("test1").arg("42");
LOG_ERROR(logger_ex, LOG_READING_LOCAL_FILE).arg("dummy/file");
LOG_WARN(logger_ex, LOG_BAD_STREAM).arg("example");
LOG_WARN(logger_alpha, LOG_READ_ERROR).arg("a.txt").arg("dummy reason");
LOG_INFO(logger_alpha, LOG_INPUT_OPEN_FAIL).arg("example.msg").arg("dummy reason");
LOG_DEBUG(logger_ex, 0, LOG_READING_LOCAL_FILE).arg("example/0");
LOG_DEBUG(logger_ex, 24, LOG_READING_LOCAL_FILE).arg("example/24");
LOG_DEBUG(logger_ex, 25, LOG_READING_LOCAL_FILE).arg("example/25");
LOG_DEBUG(logger_ex, 26, LOG_READING_LOCAL_FILE).arg("example/26");
LOG_FATAL(logger_beta, LOG_BAD_SEVERITY).arg("beta_fatal");
LOG_ERROR(logger_beta, LOG_BAD_DESTINATION).arg("beta_error");
LOG_WARN(logger_beta, LOG_BAD_STREAM).arg("beta_warn");
LOG_INFO(logger_beta, LOG_READ_ERROR).arg("beta").arg("info");
LOG_DEBUG(logger_beta, 25, LOG_BAD_SEVERITY).arg("beta/25");
LOG_DEBUG(logger_beta, 26, LOG_BAD_SEVERITY).arg("beta/26");