11 #include <stk_util/environment/LogControl.hpp> 17 typedef std::map<std::ostream *, LogControl *> OStreamLogControlMap;
19 OStreamLogControlMap &
20 get_ostream_log_control_map()
22 static OStreamLogControlMap s_ostreamLogControlMap;
24 return s_ostreamLogControlMap;
30 LogControlRuleInterval::LogControlRuleInterval(
32 : m_interval(interval),
38 LogControlRuleInterval::next()
46 else if (m_count == 0) {
51 return m_count%m_interval == 0 ? true :
false;
57 std::ostream & log_ostream,
62 m_logStream(log_ostream),
63 m_logStreambuf(log_ostream.rdbuf()),
66 OStreamLogControlMap &ostream_log_control_map = get_ostream_log_control_map();
69 m_parent = ostream_log_control_map[&m_logStream];
70 ostream_log_control_map[&m_logStream] =
this;
73 for (
LogControl *parent = m_parent; parent != 0; parent = parent->m_parent)
74 m_logStreambuf = parent->m_logStream.rdbuf();
98 OStreamLogControlMap &ostream_log_control_map = get_ostream_log_control_map();
101 ostream_log_control_map[&m_logStream] = m_parent;
105 if (!m_parent || m_parent->m_state ==
ON) {
106 m_logStream.rdbuf(m_logStreambuf);
107 if (m_state ==
CACHE)
108 m_logStream << m_cacheStream.str();
111 m_logStream.rdbuf(m_parent->m_cacheStream.rdbuf());
112 m_parent->m_cacheStream << m_cacheStream.str();
122 m_logStream.rdbuf(m_logStreambuf);
123 m_logStream << m_cacheStream.str();
124 m_cacheStream.str(
"");
132 m_cacheStream.str(
"");
134 if (m_parent && m_parent->m_state ==
CACHE)
139 if (m_state !=
CACHE) {
140 if (m_logStream.rdbuf() != m_logStreambuf) {
141 m_logStream.rdbuf(m_logStreambuf);
145 if (m_logStream.rdbuf() != m_cacheStream.rdbuf())
146 m_logStream.rdbuf(m_cacheStream.rdbuf());
virtual bool next()=0
Member function next returns true if the log stream should write to the log file, and false if the lo...
Output is to be written to the cache stream.
LogControl(std::ostream &log_stream, const LogControlRule &rule)
void fail()
Member function fail writes the cached output to the log stream due to an error.
void next()
Member function next executes the rule and sets the log stream to write to the log file if true and t...
Class LogControl provides a mechanism for reducing excessive output. The output is redirected to a ca...
Interface LogControlRule describes the interface to a log control rule.
Output is to be written to the log stream.