Chi-Tech
chi_logstream.h
Go to the documentation of this file.
1
#ifndef CHI_LOGSTREAM_H
2
#define CHI_LOGSTREAM_H
3
4
#include <iostream>
5
#include <sstream>
6
7
namespace
chi
8
{
9
//###################################################################
10
/** Log stream for adding header information to a string stream.*/
11
class
LogStream
:
public
std::stringstream
12
{
13
private
:
14
std::ostream*
log_stream_
;
15
std::string
log_header_
;
16
const
bool
dummy_
=
false
;
17
18
public
:
19
/** Creates a string stream.*/
20
LogStream
(std::ostream* output_stream,
21
std::string header,
22
bool
dummy_flag=
false
) :
23
log_stream_
(output_stream),
24
log_header_
(std::move(header)),
25
dummy_
(dummy_flag)
26
{ }
27
28
/** Flushes the broken-up/headered stream to the output.*/
29
virtual
~LogStream
();
30
31
LogStream
(
const
LogStream
& other)
32
{
33
log_stream_
= other.
log_stream_
;
34
log_header_
= other.
log_header_
;
35
}
36
};
37
38
struct
DummyStream
:
public
std::ostream
39
{
40
struct
DummyStreamBuffer
: std::streambuf
41
{
42
virtual
int
overflow
(
int
c) {
return
c; };
43
}
buffer
;
44
45
DummyStream
(): std::ostream(&
buffer
) {}
46
47
~DummyStream
() {}
48
};
49
}
//namespace chi_objects
50
#endif
//CHI_LOGSTREAM_H
chi::LogStream
Definition:
chi_logstream.h:12
chi::LogStream::log_stream_
std::ostream * log_stream_
Definition:
chi_logstream.h:14
chi::LogStream::LogStream
LogStream(const LogStream &other)
Definition:
chi_logstream.h:31
chi::LogStream::~LogStream
virtual ~LogStream()
Definition:
chi_logstream.cc:5
chi::LogStream::dummy_
const bool dummy_
Definition:
chi_logstream.h:16
chi::LogStream::LogStream
LogStream(std::ostream *output_stream, std::string header, bool dummy_flag=false)
Definition:
chi_logstream.h:20
chi::LogStream::log_header_
std::string log_header_
Definition:
chi_logstream.h:15
chi
Definition:
chi_runtime.h:53
chi::DummyStream::DummyStreamBuffer
Definition:
chi_logstream.h:41
chi::DummyStream::DummyStreamBuffer::overflow
virtual int overflow(int c)
Definition:
chi_logstream.h:42
chi::DummyStream
Definition:
chi_logstream.h:39
chi::DummyStream::~DummyStream
~DummyStream()
Definition:
chi_logstream.h:47
chi::DummyStream::DummyStream
DummyStream()
Definition:
chi_logstream.h:45
chi::DummyStream::buffer
chi::DummyStream::DummyStreamBuffer buffer
framework
logging
chi_logstream.h
Generated by
1.9.3