Merge pull request #135 from qilicun/add-prtinfo-type

Add prtinfo type
This commit is contained in:
Atgeirr Flø Rasmussen
2016-06-08 11:35:18 +02:00
6 changed files with 32 additions and 7 deletions

View File

@@ -51,6 +51,9 @@ namespace Log {
case MessageType::Debug:
prefix = "debug";
break;
case MessageType::Note:
prefix = "note";
break;
case MessageType::Info:
prefix = "info";
break;
@@ -78,6 +81,7 @@ namespace Log {
switch (messageType) {
case MessageType::Debug:
case MessageType::Info:
case MessageType::Note:
return message; // No color coding, not even the code for default color.
case MessageType::Warning:
return AnsiTerminalColors::blue_strong + message + AnsiTerminalColors::none;

View File

@@ -27,15 +27,17 @@ namespace Opm {
namespace Log {
namespace MessageType {
const int64_t Debug = 1; /* Excessive information */
const int64_t Info = 2; /* Normal status information */
const int64_t Warning = 4; /* Input anomaly - possible error */
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 Note = 2; /* Information that should only go into print file.*/
const int64_t Info = 4; /* Normal status information */
const int64_t Warning = 8; /* Input anomaly - possible error */
const int64_t Error = 16; /* Error in the input data - should probably exit. */
const int64_t Problem = 32; /* Calculation problems - e.g. convergence failure. */
const int64_t Bug = 64; /* An inconsistent state has been encountered in the simulator - should probably exit. */
}
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::Note + MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
const int64_t NoDebugMessageTypes = MessageType::Info + MessageType::Note + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
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::Note , "note");
}
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::note(const std::string& message)
{
addMessage(Log::MessageType::Note, message);
}
void OpmLog::info(const std::string& tag, const std::string& message)
{
@@ -119,6 +125,13 @@ namespace Opm {
void OpmLog::note(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Note, 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 note(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 note(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::Note , "This is a note");
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::Note ));
{
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::Note, "message"), "note: message");
// colorCode Message
BOOST_CHECK_EQUAL(colorCodeMessage(MessageType::Info, "message"), "message");