The Gaudi Framework  v36r6 (b1ee9983)
Gaudi::Monitoring::MessageSvcSink Class Reference
Inheritance diagram for Gaudi::Monitoring::MessageSvcSink:
Collaboration diagram for Gaudi::Monitoring::MessageSvcSink:

Public Member Functions

StatusCode initialize () override
 initialization, registers to Monitoring::Hub More...
 
StatusCode stop () override
 stop method, handles the printing More...
 
void registerEntity (Hub::Entity ent) override
 
void removeEntity (Hub::Entity const &ent) override
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service
More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service
More...
 
StatusCode sysStart () override
 Initialize Service
More...
 
StatusCode sysStop () override
 Initialize Service
More...
 
StatusCode sysFinalize () override
 Finalize Service
More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from Gaudi::Monitoring::Hub::Sink
virtual ~Sink ()=default
 

Private Attributes

std::deque< Hub::Entitym_monitoringEntities
 

Additional Inherited Members

- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] unused" }
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Detailed Description

Definition at line 157 of file MessageSvcSink.cpp.

Member Function Documentation

◆ initialize()

StatusCode Gaudi::Monitoring::MessageSvcSink::initialize ( )
inlineoverride

initialization, registers to Monitoring::Hub

Definition at line 163 of file MessageSvcSink.cpp.

163  {
164  return Service::initialize().andThen( [&] {
165  // declare ourself as a monitoding sink
166  serviceLocator()->monitoringHub().addSink( this );
167  } );
168  }

◆ registerEntity()

void Gaudi::Monitoring::MessageSvcSink::registerEntity ( Hub::Entity  ent)
inlineoverridevirtual

Implements Gaudi::Monitoring::Hub::Sink.

Definition at line 174 of file MessageSvcSink.cpp.

174  {
175  if ( std::string_view( ent.type ).substr( 0, 8 ) == "counter:" || ent.type == "statentity" ||
176  ent.type == "histogram" ) {
177  m_monitoringEntities.emplace_back( std::move( ent ) );
178  }
179  }

◆ removeEntity()

void Gaudi::Monitoring::MessageSvcSink::removeEntity ( Hub::Entity const &  ent)
inlineoverridevirtual

Implements Gaudi::Monitoring::Hub::Sink.

Definition at line 182 of file MessageSvcSink.cpp.

182  {
184  if ( it != m_monitoringEntities.end() ) { m_monitoringEntities.erase( it ); }
185  }

◆ Service()

Service::Service

Standard Constructor

Definition at line 81 of file Service.cpp.

339  : m_name( std::move( name ) ), m_svcLocator( svcloc ) {
340  if ( m_name != "MessageSvc" ) { // the MessageSvc should not notify itself
343  }
344 
345  // Initialize the default value from ApplicationMgr AuditAlgorithms
346  Gaudi::Property<bool> audit( false );
347  auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" );
348  if ( appMgr && appMgr->hasProperty( "AuditServices" ) ) { audit.assign( appMgr->getProperty( "AuditServices" ) ); }
349  m_auditInit = audit;
350  m_auditorInitialize = audit;
351  m_auditorStart = audit;
352  m_auditorStop = audit;
353  m_auditorFinalize = audit;
354  m_auditorReinitialize = audit;
355  m_auditorRestart = audit;
356 }

◆ stop()

StatusCode Gaudi::Monitoring::MessageSvcSink::stop ( )
override

stop method, handles the printing

Definition at line 194 of file MessageSvcSink.cpp.

194  {
195  // We will try to mimic the old monitoring of counters, so we need to split
196  // them per Algo. The algo name can be extracted form the id of the entity
197  // as its format is "algoName/counterName"
198  // This map groups entities per algoName. For each name, the submap gives
199  // the counter name of each subentity and the associated json
201  // fill the sorted map
202  for ( auto& entity : m_monitoringEntities ) { sortedEntities[entity.component][entity.name] = entity.toJSON(); }
203  // dump all counters
204  for ( auto& [algoName, entityMap] : sortedEntities ) {
205  // check first whether there is any counter to log
206  unsigned int nbCounters =
207  std::accumulate( begin( entityMap ), end( entityMap ), 0, []( const unsigned int& a, const auto& j ) {
208  return a + ( j.second.at( "empty" ).template get<bool>() ? 0 : 1 );
209  } );
210  if ( 0 == nbCounters ) continue;
211  MsgStream log{ msgSvc(), algoName };
212  log << MSG::INFO << "Number of counters : " << nbCounters << "\n"
213  << " | Counter | # | "
214  << " sum | mean/eff^* | rms/err^* | min | max |";
215  std::for_each( begin( entityMap ), end( entityMap ), [&log]( auto& p ) {
216  // Do not print empty counters
217  if ( !p.second.at( "empty" ).template get<bool>() ) {
218  log << "\n";
219  printCounter( log, p.first, p.second );
220  }
221  } );
222  log << endmsg;
223  }
224  return Service::stop();
225 }

Member Data Documentation

◆ m_monitoringEntities

std::deque<Hub::Entity> Gaudi::Monitoring::MessageSvcSink::m_monitoringEntities
private

Definition at line 188 of file MessageSvcSink.cpp.


The documentation for this class was generated from the following file:
Service::m_auditorStart
Gaudi::Property< bool > m_auditorStart
Definition: Service.h:232
Service::m_auditorStop
Gaudi::Property< bool > m_auditorStop
Definition: Service.h:233
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
std::for_each
T for_each(T... args)
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
Gaudi.Configuration.log
log
Definition: Configuration.py:28
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
std::move
T move(T... args)
MSG::INFO
@ INFO
Definition: IMessageSvc.h:25
std::find
T find(T... args)
Service::m_auditorInitialize
Gaudi::Property< bool > m_auditorInitialize
Definition: Service.h:231
Service::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference
Definition: Service.h:215
Service::m_auditorReinitialize
Gaudi::Property< bool > m_auditorReinitialize
Definition: Service.h:235
Service::m_name
std::string m_name
Service Name
Definition: Service.h:213
Service::m_auditInit
Gaudi::Property< bool > m_auditInit
Definition: Service.h:230
IProperty
Definition: IProperty.h:33
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
Service::m_auditorFinalize
Gaudi::Property< bool > m_auditorFinalize
Definition: Service.h:234
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
Service::m_auditorRestart
Gaudi::Property< bool > m_auditorRestart
Definition: Service.h:236
Gaudi::Property::declareUpdateHandler
Details::PropertyBase & declareUpdateHandler(std::function< void(Details::PropertyBase &)> fun) override
set new callback for update
Definition: Property.h:146
CommonMessaging< implements< IService, IProperty, IStateful > >::updateMsgStreamOutputLevel
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Definition: CommonMessaging.h:185
std::accumulate
T accumulate(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
std::map
STL class.
MsgStream
Definition: MsgStream.h:34
IOTest.end
def end
Definition: IOTest.py:128
Gaudi::Monitoring::MessageSvcSink::m_monitoringEntities
std::deque< Hub::Entity > m_monitoringEntities
Definition: MessageSvcSink.cpp:188
Service::stop
StatusCode stop() override
Definition: Service.cpp:181
AsyncIncidents.msgSvc
msgSvc
Definition: AsyncIncidents.py:34
IOTest.appMgr
appMgr
Definition: IOTest.py:108
Service::m_outputLevel
Gaudi::Property< int > m_outputLevel
flag indicating whether ToolHandle tools have been added to m_tools
Definition: Service.h:229
Gaudi::Property< bool >
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335