Merge pull request #142 from qilicun/minor-format-change

use the 'msg + file name + line number' format.
This commit is contained in:
Atgeirr Flø Rasmussen 2016-06-15 14:20:28 +02:00 committed by GitHub
commit 01c6f9fbc8
2 changed files with 4 additions and 4 deletions

View File

@ -35,7 +35,7 @@ namespace Log {
std::string fileMessage(const std::string& filename , int line , const std::string& message) {
std::ostringstream oss;
oss << filename << ":" << line << ": " << message;
oss << message << "\n" << "In file " << filename << ", line " << line << "\n";
return oss.str();
}

View File

@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(DoLogging) {
BOOST_AUTO_TEST_CASE(Test_Format) {
BOOST_CHECK_EQUAL( "/path/to/file:100: There is a mild fuckup here?" , Log::fileMessage("/path/to/file" , 100 , "There is a mild fuckup here?"));
BOOST_CHECK_EQUAL( "There is a mild fuckup here?\nIn file /path/to/file, line 100\n" , Log::fileMessage("/path/to/file" , 100 , "There is a mild fuckup here?"));
BOOST_CHECK_EQUAL( "Error: This is the error" , Log::prefixMessage(Log::MessageType::Error , "This is the error"));
BOOST_CHECK_EQUAL( "Warning: This is the warning" , Log::prefixMessage(Log::MessageType::Warning , "This is the warning"));
@ -248,8 +248,8 @@ BOOST_AUTO_TEST_CASE(TestHelperFunctions)
BOOST_CHECK(isPower2(1ul << 62));
// fileMessage
BOOST_CHECK_EQUAL(fileMessage("foo/bar", 1, "message"), "foo/bar:1: message");
BOOST_CHECK_EQUAL(fileMessage(MessageType::Error, "foo/bar", 1, "message"), "foo/bar:1: Error: message");
BOOST_CHECK_EQUAL(fileMessage("foo/bar", 1, "message"), "message\nIn file foo/bar, line 1\n");
BOOST_CHECK_EQUAL(fileMessage(MessageType::Error, "foo/bar", 1, "message"), "Error: message\nIn file foo/bar, line 1\n");
// prefixMessage
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Error, "message"), "Error: message");