Add a new message type that allows messages only go into print file.

This commit is contained in:
Liu Ming 2016-06-07 14:08:33 +02:00
parent 1278e431ae
commit 314a3ffec7
6 changed files with 24 additions and 2 deletions

View File

@ -52,6 +52,7 @@ namespace Log {
prefix = "debug";
break;
case MessageType::Info:
case MessageType::Prtinfo:
prefix = "info";
break;
case MessageType::Warning:

View File

@ -32,10 +32,12 @@ namespace Log {
const int64_t Error = 8; /* Error in the input data - should probably exit. */
const int64_t Problem = 16; /* Calculation problems - e.g. convergence failure. */
const int64_t Bug = 32; /* An inconsistent state has been encountered in the simulator - should probably exit. */
const int64_t Prtinfo = 64; /* Information that should only go into print file.*/
}
const int64_t DefaultMessageTypes = MessageType::Debug + MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
const int64_t NoDebugMessageTypes = MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
const int64_t DefaultMessageTypes = MessageType::Debug + MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug + MessageType::Prtinfo;
const int64_t NoDebugMessageTypes = MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug + MessageType::Prtinfo;
const int64_t StdoutMessageTypes = MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
/// Terminal codes for ANSI/vt100 compatible terminals.
/// See for example http://ascii-table.com/ansi-escape-sequences.php

View File

@ -36,6 +36,7 @@ namespace Opm {
addMessageType( Log::MessageType::Error , "error");
addMessageType( Log::MessageType::Problem , "problem");
addMessageType( Log::MessageType::Bug , "bug");
addMessageType( Log::MessageType::Prtinfo , "prtinfo");
}
void Logger::addTaggedMessage(int64_t messageType, const std::string& tag, const std::string& message) const {

View File

@ -81,6 +81,12 @@ namespace Opm {
}
void OpmLog::prtinfo(const std::string& message)
{
addMessage(Log::MessageType::Prtinfo, message);
}
void OpmLog::info(const std::string& tag, const std::string& message)
{
@ -119,6 +125,13 @@ namespace Opm {
void OpmLog::prtinfo(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Prtinfo, tag, message);
}
bool OpmLog::enabledMessageType( int64_t messageType ) {
if (m_logger)

View File

@ -48,6 +48,7 @@ public:
static void problem(const std::string& message);
static void bug(const std::string& message);
static void debug(const std::string& message);
static void prtinfo(const std::string& message);
static void info(const std::string& tag, const std::string& message);
static void warning(const std::string& tag, const std::string& message);
@ -55,6 +56,7 @@ public:
static void problem(const std::string& tag, const std::string& message);
static void bug(const std::string& tag, const std::string& message);
static void debug(const std::string& tag, const std::string& message);
static void prtinfo(const std::string& tag, const std::string& message);
static bool hasBackend( const std::string& backendName );
static void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);

View File

@ -169,10 +169,12 @@ BOOST_AUTO_TEST_CASE( CounterLogTesting) {
counter.addMessage( Log::MessageType::Error , "This is an error ...");
counter.addMessage( Log::MessageType::Warning , "This is a warning");
counter.addMessage( Log::MessageType::Prtinfo , "This is a info(prtinfo)");
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Error ));
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Warning ));
BOOST_CHECK_EQUAL(0 , counter.numMessages( Log::MessageType::Info ));
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Prtinfo ));
{
int64_t not_enabled = 4096;
@ -252,6 +254,7 @@ BOOST_AUTO_TEST_CASE(TestHelperFunctions)
// prefixMessage
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Error, "message"), "error: message");
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Info, "message"), "info: message");
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Prtinfo, "message"), "info: message");
// colorCode Message
BOOST_CHECK_EQUAL(colorCodeMessage(MessageType::Info, "message"), "message");