• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Open-Sn / opensn / 20185909776

12 Dec 2025 06:55PM UTC coverage: 74.333% (+0.3%) from 74.037%
20185909776

push

github

web-flow
Merge pull request #859 from wdhawkins/td_source_driver

Adding time-dependent solver and time-dependent sources

367 of 398 new or added lines in 23 files covered. (92.21%)

113 existing lines in 28 files now uncovered.

18610 of 25036 relevant lines covered (74.33%)

68947552.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/framework/logging/log_stream.h
1
// SPDX-FileCopyrightText: 2024 The OpenSn Authors <https://open-sn.github.io/opensn/>
2
// SPDX-License-Identifier: MIT
3

4
#pragma once
5

6
#include <iostream>
7
#include <sstream>
8
#include "stringstream_color.h"
9

10
namespace opensn
11
{
12

13
/// Log stream for adding header information to a string stream.
14
class LogStream : public std::stringstream
15
{
16
public:
17
  LogStream(std::ostream* output_stream,
1,101,017✔
18
            std::string header,
19
            bool dummy_flag = false,
20
            bool use_color = false)
21
    : log_stream_(output_stream),
2,202,034✔
22
      log_header_(std::move(header)),
1,101,017✔
23
      dummy_(dummy_flag),
1,101,017✔
24
      use_color_(use_color)
1,101,017✔
25
  {
26
  }
1,101,017✔
27

28
  LogStream(const LogStream&) = delete;
29
  LogStream& operator=(const LogStream&) = delete;
30

31
  ~LogStream() noexcept override
1,101,017✔
32
  {
33
    if (dummy_)
34
      return;
35

36
    try
37
    {
38
      std::string content = this->str();
39
      if (content.empty())
40
        return;
41

42
      std::istringstream iss(content);
43
      std::string line;
44
      std::string oline;
45
      std::string reset_str = use_color_ ? StringStreamColor(StringStreamColorCode::RESET) : "";
46
      while (std::getline(iss, line))
47
      {
48
        oline += log_header_;
49
        oline += line;
50
        oline += reset_str;
51
        oline += "\n";
52
      }
53

54
      if (!oline.empty())
55
        *log_stream_ << oline << std::flush;
56
    }
57
    catch (...) // NOLINT(bugprone-empty-catch)
58
    {
59
      // No exceptions escape the destructor...
60
    }
61
  }
1,101,017✔
62

1,101,017✔
63
private:
1,101,017✔
64
  std::ostream* log_stream_;
18,353✔
65
  std::string log_header_;
18,353✔
66
  const bool dummy_;
18,353✔
UNCOV
67
  bool use_color_;
×
68
};
18,353✔
69

18,353✔
70
struct DummyStream : public std::ostream
18,353✔
71
{
18,353✔
72
  struct DummyStreamBuffer : std::streambuf
60,748✔
73
  {
24,042✔
74
    int overflow(int c) override { return c; };
24,042✔
75
  } buffer;
24,042✔
76

42,395✔
77
  DummyStream() : std::ostream(&buffer) {}
18,353✔
78
  ~DummyStream() override = default;
18,353✔
79
};
18,353✔
UNCOV
80

×
UNCOV
81
} // namespace opensn
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc