2 #include "RelationalAccess/MonitoringException.h"
3 #include "CoralBase/MessageStream.h"
4 #include "CoralBase/TimeStamp.h"
5 #include "CoralKernel/Context.h"
6 #include "CoralKernel/IHandle.h"
17 : active( act ),
level( lvl ), stream()
33 Repository::const_iterator rit;
43 if( level == coral::monitor::Off )
55 Repository::const_iterator rit;
58 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::level", this->
name() );
60 return (*rit).second.level;
65 Repository::const_iterator rit;
68 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::active", this->
name() );
70 return (*rit).second.active;
75 Repository::iterator rit;
78 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::enable", this->
name() );
80 (*rit).second.active =
true;
85 Repository::iterator rit;
88 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::disable", this->
name() );
90 (*rit).second.active =
false;
96 Repository::iterator rit;
99 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string& )", this->
name() );
101 bool active = (*rit).second.active;
106 (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description ) );
112 Repository::iterator rit;
115 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, int )", this->
name() );
117 bool active = (*rit).second.active;
122 (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
128 Repository::iterator rit;
131 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, long long )", this->
name() );
133 bool active = (*rit).second.active;
138 (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
144 Repository::iterator rit;
147 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, double )", this->
name() );
149 bool active = (*rit).second.active;
154 (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
160 Repository::iterator rit;
163 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record( const std::string& , coral::monitor::Source, coral::monitor::Type, const std::string&, const std::string& )", this->
name() );
165 bool active = (*rit).second.active;
170 (*rit).second.stream.push_back( coral::monitor::createEvent( source, type, description, data ) );
176 return( static_cast<const coral::IMonitoringReporter&>(*
this) );
187 Repository::const_iterator rit;
188 coral::MessageStream
log(
"MonitoringService" );
197 Repository::const_iterator rit;
200 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record", this->
name() );
203 coral::MessageStream
log(
"MonitoringService" );
210 Repository::const_iterator rit;
213 throw coral::MonitoringException(
"Monitoring for session " + contextKey +
" not initialized...",
"MonitoringService::record", this->
name() );
216 coral::MessageStream
log(
"MonitoringService" );
224 switch( it->m_source ) {
225 case coral::monitor::Application:
226 source =
"Application";
228 case coral::monitor::Session:
231 case coral::monitor::Transaction:
232 source =
"Transaction";
234 case coral::monitor::Statement:
235 source =
"Statement";
242 switch( it->m_type ) {
243 case coral::monitor::Info:
246 case coral::monitor::Time:
249 case coral::monitor::Warning:
252 case coral::monitor::Error:
255 case coral::monitor::Config:
262 if(it->m_source == coral::monitor::Statement || it->m_source == coral::monitor::Transaction)
264 os << boost::posix_time::to_iso_extended_string((*it).m_time.time()) <<
": "
267 <<(*it).m_description <<
";"<< std::endl;
275 switch( it->m_source ) {
276 case coral::monitor::Application:
277 source =
"Application";
279 case coral::monitor::Session:
282 case coral::monitor::Transaction:
283 source =
"Transaction";
285 case coral::monitor::Statement:
286 source =
"Statement";
293 switch( it->m_type ) {
294 case coral::monitor::Info:
297 case coral::monitor::Time:
300 case coral::monitor::Warning:
303 case coral::monitor::Error:
306 case coral::monitor::Config:
313 if(it->m_source == coral::monitor::Statement || it->m_source == coral::monitor::Transaction)
315 os << boost::posix_time::to_iso_extended_string((*it).m_time.time()) <<
": "
318 << (*it).m_description <<coral::MessageStream::flush;
324 os <<
"Session: " << (*it).first << std::endl;
326 switch( (*it).second.level ) {
327 case (coral::monitor::Off) : lvl =
"Off";
break;
328 case (coral::monitor::Minimal) : lvl =
"Minimal";
break;
331 case (coral::monitor::Trace) : lvl =
"Trace";
break;
334 os <<
"Monitoring Level: " << lvl << std::endl;
337 os <<
" Recorded " << evsref.size() <<
" events" << std::endl;
339 for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
347 os <<
"Session: " << (*it).first;
349 switch( (*it).second.level ) {
350 case (coral::monitor::Off) : lvl =
"Off";
break;
351 case (coral::monitor::Minimal) : lvl =
"Minimal";
break;
354 case (coral::monitor::Trace) : lvl =
"Trace";
break;
357 os <<
" monitored at level: " << lvl;
360 os << lvl <<
" has recorded " << evsref.size() <<
" events" << coral::MessageStream::endmsg;
362 for( EventStream::const_iterator evit = evsref.begin(); evit != evsref.end(); ++evit )
SQLMonitoringService(const std::string &)
virtual void disable(const std::string &contextKey)
void reportOnEvent(EventStream::const_iterator &it, std::ostream &os) const
virtual ~SQLMonitoringService()
#define DEFINE_CORALSERVICE(type, name)
virtual void record(const std::string &contextKey, coral::monitor::Source source, coral::monitor::Type type, const std::string &description)
virtual void reportToOutputStream(const std::string &contextKey, std::ostream &os, unsigned int level) const
virtual std::set< std::string > monitoredDataSources() const
virtual void report(unsigned int level) const
virtual void setLevel(const std::string &contextKey, coral::monitor::Level level)
std::vector< coral::monitor::Event::Record > EventStream
The raw stream of recorder monitoring events.
virtual const coral::IMonitoringReporter & reporter() const
The session related book-keeping of monitored events.
virtual void enable(const std::string &contextKey)
Repository m_events
The all events repository classified by the sessions' keys.
void reportForSession(Repository::const_iterator &it, std::ostream &os) const
char data[epos_bytes_allocation]
virtual coral::monitor::Level level(const std::string &contextKey) const
volatile std::atomic< bool > shutdown_flag false
virtual bool active(const std::string &contextKey) const
std::set< std::string > m_monitoredDS
static std::string const source