Removed methods from CounterLog:
- Methods to get the number of Warning, Errors and Notes. - Methods to get the file/line/description content of a message.
This commit is contained in:
parent
3a60605d99
commit
f3419e8e61
@ -257,7 +257,7 @@ BOOST_AUTO_TEST_CASE(PropertiesNotSupportedThrows) {
|
||||
DeckKeywordConstPtr swat = deck->getKeyword("SWAT");
|
||||
BOOST_CHECK_EQUAL( false , state.supportsGridProperty("SWAT"));
|
||||
state.loadGridPropertyFromDeckKeyword(std::make_shared<const Box>(10,10,10), swat, logger);
|
||||
BOOST_CHECK(logger->numErrors() > 0);
|
||||
BOOST_CHECK_EQUAL( 1 , logger->numMessages(Log::MessageType::Error) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) {
|
||||
BOOST_AUTO_TEST_CASE( INCOMPLETE_KEYWORD_BOX) {
|
||||
CounterLogPtr logger(new CounterLog());
|
||||
makeState("testdata/integration_tests/BOX/BOXTEST2", logger);
|
||||
BOOST_CHECK(logger->numErrors() > 1);
|
||||
BOOST_CHECK(logger->numMessages(Log::MessageType::Error) > 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,25 +31,10 @@ namespace Opm {
|
||||
CounterLog::CounterLog(int64_t messageTypes) : LogBackend(messageTypes)
|
||||
{ }
|
||||
|
||||
|
||||
CounterLog::CounterLog() : LogBackend(Log::DefaultMessageTypes)
|
||||
{ }
|
||||
|
||||
|
||||
|
||||
size_t CounterLog::numErrors() const {
|
||||
return numMessages( Log::MessageType::Error );
|
||||
}
|
||||
|
||||
size_t CounterLog::numWarnings() const {
|
||||
return numMessages( Log::MessageType::Warning );
|
||||
}
|
||||
|
||||
size_t CounterLog::numNotes() const {
|
||||
return numMessages( Log::MessageType::Note );
|
||||
}
|
||||
|
||||
|
||||
size_t CounterLog::numMessages(int64_t messageType) const {
|
||||
if (Log::isPower2( messageType )) {
|
||||
auto iter = m_count.find( messageType );
|
||||
@ -63,7 +48,7 @@ size_t CounterLog::numMessages(int64_t messageType) const {
|
||||
|
||||
|
||||
|
||||
void CounterLog::addMessage(int64_t messageType , const std::string& message) {
|
||||
void CounterLog::addMessage(int64_t messageType , const std::string& ) {
|
||||
if (includeMessage( messageType ))
|
||||
m_count[messageType]++;
|
||||
}
|
||||
@ -75,35 +60,5 @@ void CounterLog::clear()
|
||||
}
|
||||
|
||||
|
||||
const std::string& CounterLog::getFileName(size_t msgIdx) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
int CounterLog::getLineNumber(size_t msgIdx) const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t CounterLog::getMessageType(size_t msgIdx) const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string& CounterLog::getDescription(size_t msgIdx) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
const std::string CounterLog::getFormattedMessage(size_t msgIdx) const {
|
||||
const std::string& description = getDescription( msgIdx );
|
||||
int64_t messageType = getMessageType( msgIdx );
|
||||
std::string prefixedMessage = Log::prefixMessage( messageType , description);
|
||||
int lineNumber = getLineNumber(msgIdx);
|
||||
|
||||
if (lineNumber > 0) {
|
||||
const std::string& filename = getFileName(msgIdx);
|
||||
return Log::fileMessage( filename , getLineNumber(msgIdx) , prefixedMessage);
|
||||
} else
|
||||
return prefixedMessage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -39,9 +39,6 @@ public:
|
||||
CounterLog(int64_t messageMask);
|
||||
CounterLog();
|
||||
|
||||
size_t numErrors() const;
|
||||
size_t numWarnings() const;
|
||||
size_t numNotes() const;
|
||||
size_t numMessages(int64_t messageType) const;
|
||||
|
||||
|
||||
@ -49,31 +46,9 @@ public:
|
||||
const std::string& message);
|
||||
|
||||
|
||||
const std::string& getFileName(size_t msgIdx) const;
|
||||
int getLineNumber(size_t msgIdx) const;
|
||||
int64_t getMessageType(size_t msgIdx) const;
|
||||
const std::string& getDescription(size_t msgIdx) const;
|
||||
|
||||
void clear();
|
||||
/*!
|
||||
* \brief This method takes the information provided by the methods above and returns
|
||||
* them in a fully-formatted string.
|
||||
*
|
||||
* It is thus covenience method to convert a log message into a GCC-like format,
|
||||
* e.g. a "Note" message triggered by the file "SPE1DECK.DATA" on line 15 which says
|
||||
* that no grid can be constructed would yield:
|
||||
*
|
||||
* SPE1DECK.DATA:15:note: No grid found.
|
||||
*/
|
||||
const std::string getFormattedMessage(size_t msgIdx) const;
|
||||
~CounterLog() {};
|
||||
private:
|
||||
typedef std::tuple<std::string,
|
||||
int,
|
||||
int64_t,
|
||||
std::string> MessageTuple;
|
||||
|
||||
std::vector<MessageTuple> m_messages;
|
||||
std::map<int64_t , size_t> m_count;
|
||||
};
|
||||
|
||||
|
@ -81,9 +81,9 @@ BOOST_AUTO_TEST_CASE(Test_Logger) {
|
||||
|
||||
logger.addMessage( Log::MessageType::Error , "Error");
|
||||
logger.addMessage( Log::MessageType::Warning , "Warning");
|
||||
BOOST_CHECK_EQUAL( 1U , counter->numWarnings() );
|
||||
BOOST_CHECK_EQUAL( 1U , counter->numErrors() );
|
||||
BOOST_CHECK_EQUAL( 0U , counter->numNotes() );
|
||||
BOOST_CHECK_EQUAL( 1U , counter->numMessages(Log::MessageType::Error) );
|
||||
BOOST_CHECK_EQUAL( 1U , counter->numMessages(Log::MessageType::Warning) );
|
||||
BOOST_CHECK_EQUAL( 0U , counter->numMessages(Log::MessageType::Note) );
|
||||
|
||||
BOOST_CHECK_EQUAL( log_stream.str() , "Warning\n");
|
||||
|
||||
@ -91,9 +91,9 @@ BOOST_AUTO_TEST_CASE(Test_Logger) {
|
||||
BOOST_CHECK_THROW( logger.getBackend<LogBackend>("No") , std::invalid_argument );
|
||||
{
|
||||
auto counter2 = logger.getBackend<CounterLog>("COUNTER");
|
||||
BOOST_CHECK_EQUAL( 1U , counter2->numWarnings() );
|
||||
BOOST_CHECK_EQUAL( 1U , counter2->numErrors() );
|
||||
BOOST_CHECK_EQUAL( 0U , counter2->numNotes() );
|
||||
BOOST_CHECK_EQUAL( 1U , counter2->numMessages( Log::MessageType::Warning));
|
||||
BOOST_CHECK_EQUAL( 1U , counter2->numMessages( Log::MessageType::Error));
|
||||
BOOST_CHECK_EQUAL( 0 , counter2->numMessages( Log::MessageType::Note));
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,9 +213,9 @@ BOOST_AUTO_TEST_CASE(TestOpmLog) {
|
||||
{
|
||||
auto counter = OpmLog::getBackend<CounterLog>("COUNTER");
|
||||
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numWarnings() );
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numErrors() );
|
||||
BOOST_CHECK_EQUAL( 0 , counter->numNotes() );
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Error) );
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Warning) );
|
||||
BOOST_CHECK_EQUAL( 0 , counter->numMessages(Log::MessageType::Note) );
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL( log_stream.str() , "Warning\n");
|
||||
|
Loading…
Reference in New Issue
Block a user