GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 28 / 0 / 28
Functions: 100.0% 5 / 0 / 5
Branches: 100.0% 27 / 0 / 27

src/utilities/core/LogMessage.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "LogMessage.hpp"
7
8 #include <boost/regex.hpp>
9 #include <boost/lexical_cast.hpp>
10 #include <boost/algorithm/string.hpp>
11
12 namespace openstudio {
13
14 7535 LogMessage::LogMessage(LogLevel logLevel, const LogChannel& logChannel, const std::string& logMessage)
15
1/1
✓ Branch 2 taken 7535 times.
7535 : m_logLevel(logLevel), m_logChannel(logChannel), m_logMessage(logMessage) {}
16
17 477 std::vector<LogMessage> LogMessage::parseLogText(const std::string& logText) {
18 477 std::vector<LogMessage> result;
19
20
1/1
✓ Branch 1 taken 477 times.
477 std::string text = logText;
21
22 // get preceding comments
23
1/1
✓ Branch 1 taken 477 times.
477 boost::smatch matches;
24
1/1
✓ Branch 1 taken 477 times.
477 boost::regex messageRegex("\\[([^\\]]*)\\]\\s*<([\\-0-9]+)>([^\\[]*)(.*)");
25
3/3
✓ Branch 1 taken 1574 times.
✓ Branch 3 taken 1097 times.
✓ Branch 4 taken 477 times.
1574 while (boost::regex_search(text, matches, messageRegex)) {
26
3/3
✓ Branch 1 taken 1097 times.
✓ Branch 4 taken 1097 times.
✓ Branch 7 taken 1097 times.
1097 std::string channel(matches[1].first, matches[1].second);
27
1/1
✓ Branch 2 taken 1097 times.
1097 boost::trim(channel);
28
3/3
✓ Branch 1 taken 1097 times.
✓ Branch 4 taken 1097 times.
✓ Branch 7 taken 1097 times.
1097 std::string levelString(matches[2].first, matches[2].second);
29
1/1
✓ Branch 2 taken 1097 times.
1097 boost::trim(levelString);
30
3/3
✓ Branch 1 taken 1097 times.
✓ Branch 4 taken 1097 times.
✓ Branch 7 taken 1097 times.
1097 std::string message(matches[3].first, matches[3].second);
31
1/1
✓ Branch 2 taken 1097 times.
1097 boost::trim(message);
32
3/3
✓ Branch 1 taken 1097 times.
✓ Branch 4 taken 1097 times.
✓ Branch 7 taken 1097 times.
1097 std::string remainingText(matches[4].first, matches[4].second);
33
1/1
✓ Branch 2 taken 1097 times.
1097 boost::trim(remainingText);
34
35
1/1
✓ Branch 1 taken 1097 times.
1097 int level = boost::lexical_cast<int>(levelString);
36
37
2/2
✓ Branch 1 taken 1097 times.
✓ Branch 4 taken 1097 times.
1097 result.push_back(LogMessage((LogLevel)level, channel, message));
38
39 // reduce the parsed text
40
1/1
✓ Branch 1 taken 1097 times.
1097 text = remainingText;
41 1097 }
42
43 954 return result;
44 477 }
45
46 10980 LogLevel LogMessage::logLevel() const {
47 10980 return m_logLevel;
48 }
49
50 21 LogChannel LogMessage::logChannel() const {
51 21 return m_logChannel;
52 }
53
54 4824 std::string LogMessage::logMessage() const {
55 4824 return m_logMessage;
56 }
57
58 } // namespace openstudio
59