4#ifndef TRIGSERVICES_TRIGMESSAGESVC_H
5#define TRIGSERVICES_TRIGMESSAGESVC_H
8#include "tbb/concurrent_queue.h"
14#include "GaudiKernel/IIncidentListener.h"
15#include "GaudiKernel/IMessageSvc.h"
16#include "GaudiKernel/Message.h"
17#include "Gaudi/Property.h"
18#include "GaudiKernel/Service.h"
19#include "GaudiKernel/StatusCode.h"
33 throw std::logic_error(std::string(__func__) + " is not supported by TrigMessageSvc")
57class TrigMessageSvc :
public extends<Service, IMessageSvc, IIncidentListener> {
65 virtual StatusCode
start()
override;
66 virtual StatusCode
stop()
override;
67 virtual StatusCode
finalize()
override;
68 virtual void handle(
const Incident& incident )
override;
72 virtual void reportMessage(std::string source,
int type, std::string message)
override;
84 virtual int outputLevel(std::string_view source)
const override;
86 virtual void setOutputLevel(std::string_view source,
int new_level)
override;
87 virtual int messageCount(MSG::Level logLevel)
const override;
90 virtual std::string
getLogColor(
int)
const override {
return ""; }
110 Gaudi::Property<std::string>
m_defaultFormat{
this,
"Format", Message::getDefaultFormat(),
111 "Default message format"};
112 Gaudi::Property<std::string>
m_ersFormat{
this,
"ErsFormat", Message::getDefaultFormat(),
113 "ERS message format"};
115 this,
"timeFormat", Message::getDefaultTimeFormat(),
"Message time format"};
116 Gaudi::Property<bool>
m_stats{
this,
"showStats",
false,
"Show message statistics"};
118 "Show total message statistics for >= level"};
120 "Publish message statistics for this and higher message levels"};
121 Gaudi::Property<unsigned int>
m_eventIDLevel{
this,
"printEventIDLevel", MSG::NIL,
122 "Print event ID for this and higher message levels"};
123 Gaudi::Property<bool>
m_color{
this,
"useColors",
false,
124 "Colors are not supported by TrigMessageSvc"};
125 Gaudi::Property<bool>
m_suppress{
this,
"enableSuppression",
false,
"Enable message suppression"};
127 "Use message suppression only during RUNNING state"};
129 std::array<Gaudi::Property<std::vector<std::string>>, MSG::NUM_LEVELS>
m_thresholdProp{
131 {
this,
"setVerbose"},
134 {
this,
"setWarning"},
137 {
this,
"setAlways"}}};
139 std::array<Gaudi::Property<int>, MSG::NUM_LEVELS>
m_msgLimit{{{
this,
"defaultLimit", 500},
140 {
this,
"verboseLimit", 500},
141 {
this,
"debugLimit", 500},
142 {
this,
"infoLimit", 500},
143 {
this,
"warningLimit", 500},
144 {
this,
"errorLimit", 500},
145 {
this,
"fatalLimit", 500},
146 {
this,
"alwaysLimit", 0}}};
157 std::array<Gaudi::Property<std::vector<std::string>>, MSG::NUM_LEVELS>
m_useERS{
159 {
this,
"useErsVerbose", {}},
160 {
this,
"useErsDebug", {}},
161 {
this,
"useErsInfo", {}},
162 {
this,
"useErsWarning", {}},
163 {
this,
"useErsError", {}},
164 {
this,
"useErsFatal", {}},
165 {
this,
"useErsAlways", {}}}};
168 "Maximum number of messages (per event and level) that are forwarded to ERS (-1: disabled)"};
179 std::array<int, MSG::NUM_LEVELS>
msg = {{0}};
187 std::unordered_map<EventContext::ContextID_t,
202 void setupLimits(Gaudi::Details::PropertyBase& prop);
204 bool passErsFilter(
const std::string& source,
const std::vector<std::string>& filter)
const;
Define macros for attributes used to control the static checker.
virtual void eraseMessage(const StatusCode &) override
bool passErsFilter(const std::string &source, const std::vector< std::string > &filter) const
virtual std::string getLogColor(int) const override
Gaudi::Property< std::string > m_ersFormat
virtual void eraseStream(int, std::ostream *) override
tbb::concurrent_bounded_queue< std::function< void()> > m_messageActionsQueue
virtual void eraseStream(std::ostream *) override
void setupLimits(Gaudi::Details::PropertyBase &prop)
virtual int outputLevel() const override
virtual StatusCode finalize() override
void i_reportMessage(const Message &msg, int outputLevel)
Internal implementation of reportMessage(const Message&,int) without lock.
bool passErsLimit(const Message &msg)
std::array< Gaudi::Property< int >, MSG::NUM_LEVELS > m_msgLimit
virtual StatusCode start() override
Gaudi::Property< std::string > m_defaultTimeFormat
std::map< std::string, MsgAry > m_sourceMap
counts per source
std::map< size_t, unsigned int > m_msgHashCount
counts per message hash
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_thresholdProp
std::unordered_map< EventContext::ContextID_t, std::pair< EventContext::ContextEvt_t, MsgAry > > m_slotMsgCount
counts per slot and level
std::array< Gaudi::Property< std::vector< std::string > >, MSG::NUM_LEVELS > m_useERS
Special properties to control output to ERS of individual sources.
Gaudi::Property< bool > m_color
std::recursive_mutex m_thresholdMapMutex
virtual void reportMessage(const Message &message) override
TH1I * m_msgCountHist
Message counting per level histogram.
void i_reportERS(const Message &msg) const
Report message to online messaging system (ERS).
bool m_doPublish
are we publishing message statistics?
virtual void insertMessage(const StatusCode &, Message) override
Gaudi::Property< std::string > m_defaultFormat
std::map< std::string, int, std::less<> > ThresholdMap
virtual void eraseMessage(const StatusCode &, const Message &) override
ThresholdMap m_thresholdMap
Output level threshold map.
void setupThreshold(Gaudi::Details::PropertyBase &prop)
Gaudi::Property< bool > m_stats
virtual StatusCode stop() override
virtual void eraseStream() override
Gaudi::Property< bool > m_suppressRunningOnly
virtual int messageCount(MSG::Level logLevel) const override
bool m_doSuppress
is suppression currently enabled?
virtual bool useColor() const override
TH2I * m_msgCountSrcHist
Message counting per message source.
Gaudi::Property< int > m_ersEventLimit
virtual void eraseMessage() override
Gaudi::Property< unsigned int > m_statLevel
virtual void setOutputLevel(int new_level) override
std::array< int, MSG::NUM_LEVELS > m_msgCount
counts per level
virtual StatusCode reinitialize() override
virtual void handle(const Incident &incident) override
Gaudi::Property< unsigned int > m_eventIDLevel
virtual void insertStream(int, std::string, std::ostream *) override
Gaudi::Property< bool > m_suppress
std::thread m_thread
Thread for asynchronous reporting.
virtual void reportMessage(const StatusCode &, std::string_view) override
Not supported by this implementation.
Gaudi::Property< unsigned int > m_publishLevel
virtual StatusCode initialize() override
TrigMessageSvc(const std::string &name, ISvcLocator *svcloc)
std::ostream * m_defaultStream
Pointer to the output stream.
virtual void setDefaultStream(std::ostream *stream) override
virtual std::ostream *defaultStream ATLAS_NOT_CONST_THREAD_SAFE() const override
virtual void eraseStream(int) override
MsgAry()=default
Default constructor.
std::array< int, MSG::NUM_LEVELS > msg
Internal array of counters.