ATLAS Offline Software
Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <iostream>
6 #include <iomanip>
8 
9 using namespace TrigConf;
10 
15 class IMessageSvc;
16 
21 namespace Athena {
22  IMessageSvc* getMessageSvc(bool) __attribute__((weak));
23  void reportMessage(IMessageSvc*, const std::string&, int, const std::string&) __attribute__((weak));
24  int outputLevel(const IMessageSvc*, const std::string&) __attribute__((weak));
25  void setOutputLevel(IMessageSvc*, const std::string&, int) __attribute__((weak));
26 }
27 
28 
29 namespace {
30 
32  static IMessageSvc* getMessageSvc() {
33  static IMessageSvc* const msgsvc =
34  Athena::getMessageSvc!=nullptr ? Athena::getMessageSvc(/*quiet=*/true) : nullptr;
35  return msgsvc;
36  }
37 
38  static const char* const levelNames[MSGTC::NUM_LEVELS] =
39  {"NIL","VERBOSE","DEBUG","INFO","WARNING","ERROR","FATAL","ALWAYS"};
40 }
41 
42 MsgStreamTC::MsgStreamTC(const std::string& name) :
43  m_active(false),
44  m_msgLevel(MSGTC::INFO),
45  m_name(name)
46 {
47  // Initialize our own OutputLevel to the global one from the MessageSvc
49 }
50 
51 // Set message level of stream
53  lvl = (lvl >= MSGTC::NUM_LEVELS) ? MSGTC::ALWAYS : (lvl<MSGTC::NIL) ? MSGTC::NIL : lvl;
54  m_level = lvl;
55  if (getMessageSvc()) {
57  }
58 }
59 
61 {
62  if (getMessageSvc()) {
64  }
65  else {
66  std::ios::fmtflags f( std::cout.flags() );
67  std::cout << std::setw(m_width) << std::left << m_name << " " << levelNames[m_msgLevel] << " " << str() << std::endl;
68  std::cout.flags(f);
69  }
70  str(""); // Clear our buffer after message has been printed
71 }
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
TrigConf::MsgStreamTC::doOutput
void doOutput()
Print the current message buffer.
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:60
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
Athena::outputLevel
int outputLevel(const IMessageSvc *ims, const std::string &source)
Definition: getMessageSvc.cxx:47
MsgStream.h
MsgStream for TrigConf classes.
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
TrigConf::MsgStreamTC::m_name
std::string m_name
stream name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:108
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
TrigConf::MSGTC::INFO
@ INFO
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:25
TrigConf::MsgStreamTC::m_width
unsigned int m_width
width for printing owner name
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:109
LArConditionsTestConfig.msgsvc
msgsvc
Definition: LArConditionsTestConfig.py:74
Athena::setOutputLevel
void setOutputLevel(IMessageSvc *ims, const std::string &source, int level)
Definition: getMessageSvc.cxx:52
TrigConf::name
Definition: HLTChainList.h:35
TrigConf::MSGTC::NUM_LEVELS
@ NUM_LEVELS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:30
TrigConf::MsgStreamTC::MsgStreamTC
MsgStreamTC(const std::string &name)
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:42
python.TrigPSCPythonDbSetup.outputLevel
outputLevel
Definition: TrigPSCPythonDbSetup.py:30
TrigConf::MsgStreamTC::m_msgLevel
MSGTC::Level m_msgLevel
current message level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:107
__attribute__
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
Definition: TileCalibDrawerBase.h:190
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
TrigConf::MsgStreamTC::setLevel
void setLevel(MSGTC::Level lvl)
Set message level of stream.
Definition: Trigger/TrigConfiguration/TrigConfBase/Root/MsgStream.cxx:52
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
TrigConf::MsgStreamTC::m_level
MSGTC::Level m_level
stream level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:106
Athena::reportMessage
void reportMessage(IMessageSvc *ims, const std::string &source, int type, const std::string &message)
Wrappers for some of the IMessageSvc methods These can be used from libraries without explicit Gaudi ...
Definition: getMessageSvc.cxx:43