|
ATLAS Offline Software
|
#include <LoggedMessageSvc.h>
|
struct | MsgAry |
| Private helper class to keep the count of messages of a type (MSG::LEVEL). More...
|
|
|
| LoggedMessageSvc (const std::string &name, ISvcLocator *svcloc) |
|
virtual | ~LoggedMessageSvc () |
|
virtual StatusCode | reinitialize () override |
| Reinitialize Service. More...
|
|
virtual StatusCode | initialize () override |
| Initialize Service. More...
|
|
virtual StatusCode | finalize () override |
| Finalize Service. More...
|
|
virtual void | reportMessage (const Message &message) override |
|
virtual void | reportMessage (const Message &msg, int outputLevel) override |
|
virtual void | reportMessage (const StatusCode &code, std::string_view source="") override |
|
virtual void | reportMessage (std::string source, int type, std::string message) override |
|
virtual void | insertMessage (const StatusCode &code, Message message) override |
|
virtual void | eraseMessage () override |
|
virtual void | eraseMessage (const StatusCode &code) override |
|
virtual void | eraseMessage (const StatusCode &code, const Message &message) override |
|
virtual void | insertStream (int message_type, std::string name, std::ostream *stream) override |
|
virtual void | eraseStream () override |
|
virtual void | eraseStream (int message_type) override |
|
virtual void | eraseStream (int message_type, std::ostream *stream) override |
|
virtual void | eraseStream (std::ostream *stream) override |
|
virtual std::ostream *defaultStream | ATLAS_NOT_CONST_THREAD_SAFE () const override |
|
virtual void | setDefaultStream (std::ostream *stream) override |
|
virtual int | outputLevel () const override |
|
virtual int | outputLevel (std::string_view source) const override |
|
virtual void | setOutputLevel (int new_level) override |
|
virtual void | setOutputLevel (std::string_view source, int new_level) override |
|
virtual bool | useColor () const override |
|
virtual std::string | getLogColor (int logLevel) const override |
|
virtual int | messageCount (MSG::Level logLevel) const override |
|
virtual void | incrInactiveCount (MSG::Level level, std::string_view src) override |
|
virtual const std::vector< std::pair< std::string, std::string > > & | getMessages (MSG::Level level) const override |
|
virtual const std::vector< LoggedMessage > & | getKeyMessages () const override |
|
Definition at line 37 of file LoggedMessageSvc.h.
◆ ColorMap
◆ LoggedStreamsMap_t
◆ MessageMap
◆ NamedStream
◆ StreamMap
◆ ThresholdMap
◆ LoggedMessageSvc()
LoggedMessageSvc::LoggedMessageSvc |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
svcloc |
|
) |
| |
Definition at line 23 of file LoggedMessageSvc.cxx.
27 m_outputLevel = MSG::INFO;
28 declareProperty(
"Format",
m_defaultFormat = Message::getDefaultFormat() );
30 declareProperty(
"showStats",
m_stats =
false );
42 declareProperty(
"useColors",
m_color=
false);
46 declareProperty(
"errorColorCode",
m_logColors[MSG::ERROR] );
47 declareProperty(
"warningColorCode",
m_logColors[MSG::WARNING] );
48 declareProperty(
"infoColorCode",
m_logColors[MSG::INFO] );
64 declareProperty(
"enableSuppression",
m_suppress =
false );
71 declareProperty(
"loggingLevel",
m_logLevel =
MSG::FATAL,
"Message level above which all messages are saved" );
74 declareProperty(
"keywords",
m_keywords,
"keywords to scan messages for and save");
77 declareProperty(
"loggedStreams",
79 "MessageStream sources we want to dump into a logfile" );
◆ ~LoggedMessageSvc()
LoggedMessageSvc::~LoggedMessageSvc |
( |
| ) |
|
|
virtual |
Definition at line 95 of file LoggedMessageSvc.cxx.
100 for ( ; iStream != endStream; ++iStream ) {
101 delete iStream->second;
102 iStream->second =
nullptr;
◆ ATLAS_NOT_CONST_THREAD_SAFE()
virtual std::ostream* defaultStream LoggedMessageSvc::ATLAS_NOT_CONST_THREAD_SAFE |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ colTrans()
std::string LoggedMessageSvc::colTrans |
( |
const std::string & |
col, |
|
|
int |
offset |
|
) |
| |
|
private |
◆ eraseMessage() [1/3]
void LoggedMessageSvc::eraseMessage |
( |
| ) |
|
|
overridevirtual |
◆ eraseMessage() [2/3]
void LoggedMessageSvc::eraseMessage |
( |
const StatusCode & |
code | ) |
|
|
overridevirtual |
◆ eraseMessage() [3/3]
void LoggedMessageSvc::eraseMessage |
( |
const StatusCode & |
code, |
|
|
const Message & |
message |
|
) |
| |
|
overridevirtual |
◆ eraseStream() [1/4]
void LoggedMessageSvc::eraseStream |
( |
| ) |
|
|
overridevirtual |
◆ eraseStream() [2/4]
void LoggedMessageSvc::eraseStream |
( |
int |
message_type | ) |
|
|
overridevirtual |
◆ eraseStream() [3/4]
void LoggedMessageSvc::eraseStream |
( |
int |
message_type, |
|
|
std::ostream * |
stream |
|
) |
| |
|
overridevirtual |
◆ eraseStream() [4/4]
void LoggedMessageSvc::eraseStream |
( |
std::ostream * |
stream | ) |
|
|
overridevirtual |
◆ finalize()
StatusCode LoggedMessageSvc::finalize |
( |
| ) |
|
|
overridevirtual |
Finalize Service.
Definition at line 348 of file LoggedMessageSvc.cxx.
352 std::ostringstream
os;
355 os <<
"Summarizing all message counts" << endl;
357 os <<
"Listing sources of suppressed message: " << endl;
360 os <<
"=====================================================" << endl;
361 os <<
" Message Source | Level | Count" << endl;
362 os <<
"-----------------------------+---------+-------------" << endl;
367 std::map<std::string,MsgAry>::const_iterator itr;
374 os.setf(ios_base::left,ios_base::adjustfield);
380 os.setf(ios_base::right,ios_base::adjustfield);
381 os << levelNames[
ic];
386 os << itr->second.msg[
ic];
394 os <<
"=====================================================" << endl;
404 std::ostringstream
os;
405 os <<
"Listing sources of Unprotected and Unseen messages\n";
410 std::map<std::string,MsgAry>::const_iterator itr;
413 if (itr->second.msg[
ic] != 0) {
414 if (itr->first.length() > ml) { ml = itr->first.length(); }
419 for (
unsigned int i=0;
i<ml+25; ++
i) {
425 os.setf(ios_base::left,ios_base::adjustfield);
426 os <<
"Message Source";
428 os <<
"| Level | Count" << endl;
430 for (
unsigned int i=0;
i<ml+3; ++
i) {
433 os <<
"+---------+-----------" << endl;
438 if (itr->second.msg[
ic] != 0) {
441 os.setf(ios_base::left,ios_base::adjustfield);
447 os.setf(ios_base::right,ios_base::adjustfield);
448 os << levelNames[
ic];
453 os << itr->second.msg[
ic];
461 for (
unsigned int i=0;
i<ml+25; ++
i) {
472 return StatusCode::SUCCESS;
◆ getKeyMessages()
virtual const std::vector< LoggedMessage >& LoggedMessageSvc::getKeyMessages |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getLogColor()
std::string LoggedMessageSvc::getLogColor |
( |
int |
logLevel | ) |
const |
|
overridevirtual |
◆ getMessages()
const std::vector< std::pair< std::string, std::string > > & LoggedMessageSvc::getMessages |
( |
MSG::Level |
level | ) |
const |
|
overridevirtual |
◆ incrInactiveCount()
void LoggedMessageSvc::incrInactiveCount |
( |
MSG::Level |
level, |
|
|
std::string_view |
src |
|
) |
| |
|
overridevirtual |
◆ initColors()
void LoggedMessageSvc::initColors |
( |
Gaudi::Details::PropertyBase & |
prop | ) |
|
|
private |
Definition at line 151 of file LoggedMessageSvc.cxx.
156 vector<string> fatDef;
157 fatDef.push_back(
"[94;101;1m" );
164 vector<string> errDef;
165 errDef.push_back(
"[97;101;1m" );
172 vector<string> warDef;
173 warDef.push_back(
"[93;1m" );
◆ initialize()
StatusCode LoggedMessageSvc::initialize |
( |
| ) |
|
|
overridevirtual |
Initialize Service.
Definition at line 109 of file LoggedMessageSvc.cxx.
112 if(
sc.isFailure() )
return sc;
138 return StatusCode::SUCCESS;
◆ insertMessage()
void LoggedMessageSvc::insertMessage |
( |
const StatusCode & |
code, |
|
|
Message |
message |
|
) |
| |
|
overridevirtual |
◆ insertStream()
void LoggedMessageSvc::insertStream |
( |
int |
message_type, |
|
|
std::string |
name, |
|
|
std::ostream * |
stream |
|
) |
| |
|
overridevirtual |
◆ messageCount()
int LoggedMessageSvc::messageCount |
( |
MSG::Level |
logLevel | ) |
const |
|
overridevirtual |
◆ outputLevel() [1/2]
int LoggedMessageSvc::outputLevel |
( |
| ) |
const |
|
overridevirtual |
◆ outputLevel() [2/2]
int LoggedMessageSvc::outputLevel |
( |
std::string_view |
source | ) |
const |
|
overridevirtual |
◆ reinitialize()
StatusCode LoggedMessageSvc::reinitialize |
( |
| ) |
|
|
overridevirtual |
Reinitialize Service.
Definition at line 144 of file LoggedMessageSvc.cxx.
145 m_state = Gaudi::StateMachine::OFFLINE;
◆ reportMessage() [1/4]
void LoggedMessageSvc::reportMessage |
( |
const Message & |
message | ) |
|
|
overridevirtual |
◆ reportMessage() [2/4]
void LoggedMessageSvc::reportMessage |
( |
const Message & |
msg, |
|
|
int |
outputLevel |
|
) |
| |
|
overridevirtual |
Definition at line 499 of file LoggedMessageSvc.cxx.
512 if (
msg.getSource() !=
"AthenaSummarySvc") {
513 for (vector<string>::const_iterator itr=
m_keywords.value().begin(); itr!=
m_keywords.value().end(); ++itr) {
514 if (
msg.getMessage().find( *itr ) != string::npos) {
523 std::unique_ptr<Message> suppressed_msg;
529 (*iLog->second) << *cmsg << std::endl;
538 itr->second.msg[
key] += 1;
539 nmsg = itr->second.msg[
key];
554 std::string
str = levelNames[
key] +
" message limit (";
556 str +=
") reached for ";
557 str +=
msg.getSource() +
". Suppressing further output.";
558 suppressed_msg = std::make_unique<Message>(
msg.getSource(),MSG::WARNING,
str);
559 suppressed_msg->setFormat(
msg.getFormat());
560 cmsg = suppressed_msg.get();
572 while(
first != last ) {
573 std::ostream&
stream = *( (*first).second.second );
574 stream << *cmsg << std::endl;
582 (*m_defaultStream) << *cmsg << std::endl <<
std::flush;
◆ reportMessage() [3/4]
void LoggedMessageSvc::reportMessage |
( |
const StatusCode & |
code, |
|
|
std::string_view |
source = "" |
|
) |
| |
|
overridevirtual |
Definition at line 620 of file LoggedMessageSvc.cxx.
628 while(
first != last ) {
631 std::ostringstream os1;
632 os1 <<
"Status Code " <<
key.getCode() << std::ends;
642 std::ostringstream
os2;
643 os2 <<
"Status Code " <<
key.getCode() << std::ends;
◆ reportMessage() [4/4]
void LoggedMessageSvc::reportMessage |
( |
std::string |
source, |
|
|
int |
type, |
|
|
std::string |
message |
|
) |
| |
|
overridevirtual |
◆ setDefaultStream()
virtual void LoggedMessageSvc::setDefaultStream |
( |
std::ostream * |
stream | ) |
|
|
inlineoverridevirtual |
◆ setOutputLevel() [1/2]
void LoggedMessageSvc::setOutputLevel |
( |
int |
new_level | ) |
|
|
overridevirtual |
◆ setOutputLevel() [2/2]
void LoggedMessageSvc::setOutputLevel |
( |
std::string_view |
source, |
|
|
int |
new_level |
|
) |
| |
|
overridevirtual |
◆ setupColors()
void LoggedMessageSvc::setupColors |
( |
Gaudi::Details::PropertyBase & |
prop | ) |
|
|
private |
Definition at line 193 of file LoggedMessageSvc.cxx.
198 if (prop.name() ==
"fatalColorCode") {
200 }
else if (prop.name() ==
"errorColorCode") {
202 }
else if (prop.name() ==
"warningColorCode") {
204 }
else if (prop.name() ==
"infoColorCode") {
206 }
else if (prop.name() ==
"debugColorCode") {
208 }
else if (prop.name() ==
"verboseColorCode") {
210 }
else if (prop.name() ==
"alwaysColorCode") {
213 cout <<
"ERROR: Unknown message color parameter: " << prop.name()
219 vector<string>::const_iterator itr;
226 }
else if ((*itr)[0] ==
'[') {
227 code =
"\033" + *itr;
233 vector<string>::const_iterator itr2 = itr + 1;
◆ setupInactCount()
void LoggedMessageSvc::setupInactCount |
( |
Gaudi::Details::PropertyBase & |
prop | ) |
|
|
private |
Definition at line 336 of file LoggedMessageSvc.cxx.
337 if (prop.name() ==
"countInactive") {
339 BooleanProperty *
p =
dynamic_cast<BooleanProperty*
>(&prop);
341 MsgStream::enableCountInactive(
p->value());
◆ setupLimits()
void LoggedMessageSvc::setupLimits |
( |
Gaudi::Details::PropertyBase & |
prop | ) |
|
|
private |
Definition at line 245 of file LoggedMessageSvc.cxx.
248 if (prop.name() ==
"fatalLimit") {
250 }
else if (prop.name() ==
"errorLimit") {
252 }
else if (prop.name() ==
"warningLimit") {
254 }
else if (prop.name() ==
"infoLimit") {
256 }
else if (prop.name() ==
"debugLimit") {
258 }
else if (prop.name() ==
"verboseLimit") {
260 }
else if (prop.name() ==
"alwaysLimit") {
261 IntegerProperty *
p =
dynamic_cast<IntegerProperty*
>(&prop);
262 if (
p &&
p->value() != 0) {
263 cout <<
"LoggedMessageSvc ERROR: cannot suppress ALWAYS messages" << endl;
267 }
else if (prop.name() ==
"defaultLimit") {
274 cout <<
"LoggedMessageSvc ERROR: Unknown message limit parameter: "
275 << prop.name() << endl;
◆ setupLogStreams()
void LoggedMessageSvc::setupLogStreams |
( |
| ) |
|
|
private |
Definition at line 872 of file LoggedMessageSvc.cxx.
882 typedef std::map<std::string,std::string> StreamMap_t;
884 typedef StreamMap_t::const_iterator StreamMapIter;
886 for ( StreamMapIter iProp = streamMap.begin(), iEnd = streamMap.end();
890 const std::string sourceName = iProp->first;
893 std::set<std::string> outFileNames;
894 for ( StreamMapIter jProp = streamMap.begin();
897 if ( jProp->first != iProp->first ) {
898 outFileNames.insert( jProp->second );
◆ setupThreshold()
void LoggedMessageSvc::setupThreshold |
( |
Gaudi::Details::PropertyBase & |
prop | ) |
|
|
private |
Definition at line 282 of file LoggedMessageSvc.cxx.
285 if (prop.name() ==
"setFatal") {
287 }
else if (prop.name() ==
"setError") {
289 }
else if (prop.name() ==
"setWarning") {
291 }
else if (prop.name() ==
"setInfo") {
293 }
else if (prop.name() ==
"setDebug") {
295 }
else if (prop.name() ==
"setVerbose") {
297 }
else if (prop.name() ==
"setAlways") {
299 }
else if (prop.name() ==
"loggingLevel") {
300 IntegerProperty *iap =
dynamic_cast<IntegerProperty*
>( &prop );
304 }
else if (prop.name() ==
"keywords") {
305 StringArrayProperty *sap =
dynamic_cast<StringArrayProperty*
>( &prop );
306 if (sap!=
nullptr && sap->value().size() > 0) {
313 cerr <<
"LoggedMessageSvc ERROR: Unknown message theshold parameter: "
314 << prop.name() << endl;
318 StringArrayProperty *sap =
dynamic_cast<StringArrayProperty*
>( &prop);
319 if (sap ==
nullptr) {
320 std::cerr <<
"could not dcast " << prop.name()
321 <<
" to a StringArrayProperty (which it should be!)" << endl;
324 std::vector<std::string>::const_iterator itr;
325 for ( itr = sap->value().begin();
326 itr != sap->value().end();
◆ tee()
void LoggedMessageSvc::tee |
( |
const std::string & |
sourceName, |
|
|
const std::string & |
logFileName, |
|
|
const std::set< std::string > & |
declaredOutFileNames |
|
) |
| |
|
private |
Definition at line 910 of file LoggedMessageSvc.cxx.
915 std::ios_base::trunc;
919 if ( iStream != iEnd ) {
920 delete iStream->second;
921 iStream->second =
nullptr;
928 for ( iStream =
m_loggedStreams.begin(); iStream != iEnd; ++iStream ) {
929 if ( outFileNames.find(
outFileName ) != outFileNames.end() ) {
935 std::ofstream *
out =
new std::ofstream(
outFileName.c_str(), openMode );
937 if ( !
out->good() ) {
◆ useColor()
virtual bool LoggedMessageSvc::useColor |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ m_colMap
◆ m_color
BooleanProperty LoggedMessageSvc::m_color |
|
private |
◆ m_defaultFormat
std::string LoggedMessageSvc::m_defaultFormat |
|
private |
◆ m_defaultMessage
Message LoggedMessageSvc::m_defaultMessage |
|
private |
◆ m_defaultStream
std::ostream* LoggedMessageSvc::m_defaultStream |
|
private |
◆ m_defaultTimeFormat
std::string LoggedMessageSvc::m_defaultTimeFormat |
|
private |
◆ m_inactCount
BooleanProperty LoggedMessageSvc::m_inactCount |
|
private |
◆ m_inactiveMap
std::map<std::string, MsgAry, std::less<> > LoggedMessageSvc::m_inactiveMap |
|
private |
◆ m_keysUsed
bool LoggedMessageSvc::m_keysUsed |
|
private |
◆ m_keywords
StringArrayProperty LoggedMessageSvc::m_keywords |
|
private |
◆ m_logColorCodes
std::string LoggedMessageSvc::m_logColorCodes[MSG::NUM_LEVELS] |
|
private |
◆ m_logColors
StringArrayProperty LoggedMessageSvc::m_logColors[MSG::NUM_LEVELS] |
|
private |
◆ m_loggedStreams
◆ m_loggedStreamsName
std::map<std::string, std::string> LoggedMessageSvc::m_loggedStreamsName |
|
private |
◆ m_logLevel
IntegerProperty LoggedMessageSvc::m_logLevel |
|
private |
◆ m_messageMap
◆ m_messageMapMutex
std::recursive_mutex LoggedMessageSvc::m_messageMapMutex |
|
mutableprivate |
◆ m_msgCount
int LoggedMessageSvc::m_msgCount[MSG::NUM_LEVELS] |
|
private |
◆ m_msgKeyLog
std::vector< LoggedMessage > LoggedMessageSvc::m_msgKeyLog |
|
private |
◆ m_msgLimit
IntegerProperty LoggedMessageSvc::m_msgLimit[MSG::NUM_LEVELS] |
|
private |
◆ m_msgLog
std::vector< std::pair<std::string, std::string> > LoggedMessageSvc::m_msgLog[MSG::NUM_LEVELS] |
|
private |
◆ m_reportMutex
std::mutex LoggedMessageSvc::m_reportMutex |
|
mutableprivate |
◆ m_sourceMap
std::map<std::string, MsgAry, std::less<> > LoggedMessageSvc::m_sourceMap |
|
private |
◆ m_statLevel
UnsignedIntegerProperty LoggedMessageSvc::m_statLevel |
|
private |
◆ m_stats
BooleanProperty LoggedMessageSvc::m_stats |
|
private |
◆ m_streamMap
◆ m_suppress
BooleanProperty LoggedMessageSvc::m_suppress |
|
private |
◆ m_thresholdMap
◆ m_thresholdMapMutex
std::mutex LoggedMessageSvc::m_thresholdMapMutex |
|
mutableprivate |
Mutex to synchronize multiple access to m_thresholdMap (.
- See also
- MsgStream::doOutput).
Definition at line 196 of file LoggedMessageSvc.h.
◆ m_thresholdProp
StringArrayProperty LoggedMessageSvc::m_thresholdProp[MSG::NUM_LEVELS] |
|
private |
The documentation for this class was generated from the following files:
JetConstituentVector::iterator iterator
StringArrayProperty m_logColors[MSG::NUM_LEVELS]
std::vector< LoggedMessage > m_msgKeyLog
std::vector< std::pair< std::string, std::string > > m_msgLog[MSG::NUM_LEVELS]
Message m_defaultMessage
Default Message.
logLevel
If HLT PSK is set on command line read it from DB instead of COOL (ATR-25974)
void initColors(Gaudi::Details::PropertyBase &prop)
virtual int outputLevel() const override
LoggedStreamsMap_t m_loggedStreams
std::map< std::string, MsgAry, std::less<> > m_inactiveMap
std::mutex m_thresholdMapMutex
Mutex to synchronize multiple access to m_thresholdMap (.
int m_msgCount[MSG::NUM_LEVELS]
virtual StatusCode initialize() override
Initialize Service.
msgSvc
Provide convenience handles for various services.
IntegerProperty m_logLevel
::StatusCode StatusCode
StatusCode definition for legacy code.
std::recursive_mutex m_messageMapMutex
Mutex to synchronize multiple access to m_messageMap.
void tee(const std::string &sourceName, const std::string &logFileName, const std::set< std::string > &declaredOutFileNames)
IntegerProperty m_msgLimit[MSG::NUM_LEVELS]
BooleanProperty m_suppress
std::string colTrans(const std::string &, int)
std::pair< std::string, std::ostream * > NamedStream
BooleanProperty m_inactCount
std::map< std::string, MsgAry, std::less<> > m_sourceMap
virtual void setOutputLevel(int new_level) override
ThresholdMap m_thresholdMap
Output level threshold map.
std::map< std::string, std::string > m_loggedStreamsName
std::string to_string(const DetectorType &type)
void setupThreshold(Gaudi::Details::PropertyBase &prop)
std::string m_defaultTimeFormat
Default format for timestamps in the messages.
StringArrayProperty m_thresholdProp[MSG::NUM_LEVELS]
Properties controling.
void setupLimits(Gaudi::Details::PropertyBase &prop)
std::mutex m_reportMutex
Mutex to synchronize multiple threads printing.
std::ostream * m_defaultStream
Pointer to the output stream.
virtual void reportMessage(const Message &message) override
std::string m_logColorCodes[MSG::NUM_LEVELS]
StringArrayProperty m_keywords
#define ATLAS_THREAD_SAFE
StreamMap m_streamMap
Stream map.
void setupInactCount(Gaudi::Details::PropertyBase &prop)
UnsignedIntegerProperty m_statLevel
void setupColors(Gaudi::Details::PropertyBase &prop)
MessageMap m_messageMap
Message map.
std::string m_defaultFormat
Default format for the messages.