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 7540 LogMessage::LogMessage(LogLevel logLevel, const LogChannel& logChannel, const std::string& logMessage)
15
1/1
✓ Branch 2 taken 7540 times.
7540 : m_logLevel(logLevel), m_logChannel(logChannel), m_logMessage(logMessage) {}
16
17 484 std::vector<LogMessage> LogMessage::parseLogText(const std::string& logText) {
18 484 std::vector<LogMessage> result;
19
20
1/1
✓ Branch 1 taken 484 times.
484 std::string text = logText;
21
22 // get preceding comments
23
1/1
✓ Branch 1 taken 484 times.
484 boost::smatch matches;
24
1/1
✓ Branch 1 taken 484 times.
484 boost::regex messageRegex("\\[([^\\]]*)\\]\\s*<([\\-0-9]+)>([^\\[]*)(.*)");
25
3/3
✓ Branch 1 taken 1586 times.
✓ Branch 3 taken 1102 times.
✓ Branch 4 taken 484 times.
1586 while (boost::regex_search(text, matches, messageRegex)) {
26
3/3
✓ Branch 1 taken 1102 times.
✓ Branch 4 taken 1102 times.
✓ Branch 7 taken 1102 times.
1102 std::string channel(matches[1].first, matches[1].second);
27
1/1
✓ Branch 2 taken 1102 times.
1102 boost::trim(channel);
28
3/3
✓ Branch 1 taken 1102 times.
✓ Branch 4 taken 1102 times.
✓ Branch 7 taken 1102 times.
1102 std::string levelString(matches[2].first, matches[2].second);
29
1/1
✓ Branch 2 taken 1102 times.
1102 boost::trim(levelString);
30
3/3
✓ Branch 1 taken 1102 times.
✓ Branch 4 taken 1102 times.
✓ Branch 7 taken 1102 times.
1102 std::string message(matches[3].first, matches[3].second);
31
1/1
✓ Branch 2 taken 1102 times.
1102 boost::trim(message);
32
3/3
✓ Branch 1 taken 1102 times.
✓ Branch 4 taken 1102 times.
✓ Branch 7 taken 1102 times.
1102 std::string remainingText(matches[4].first, matches[4].second);
33
1/1
✓ Branch 2 taken 1102 times.
1102 boost::trim(remainingText);
34
35
1/1
✓ Branch 1 taken 1102 times.
1102 int level = boost::lexical_cast<int>(levelString);
36
37
2/2
✓ Branch 1 taken 1102 times.
✓ Branch 4 taken 1102 times.
1102 result.push_back(LogMessage((LogLevel)level, channel, message));
38
39 // reduce the parsed text
40
1/1
✓ Branch 1 taken 1102 times.
1102 text = remainingText;
41 1102 }
42
43 968 return result;
44 484 }
45
46 10986 LogLevel LogMessage::logLevel() const {
47 10986 return m_logLevel;
48 }
49
50 21 LogChannel LogMessage::logChannel() const {
51 21 return m_logChannel;
52 }
53
54 4833 std::string LogMessage::logMessage() const {
55 4833 return m_logMessage;
56 }
57
58 } // namespace openstudio
59