ATLAS Offline Software
Loading...
Searching...
No Matches
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
9using namespace TrigConf;
10
15class IMessageSvc;
16
21namespace 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
29namespace {
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
42MsgStreamTC::MsgStreamTC(const std::string& name) :
43 m_active(false),
44 m_msgLevel(MSGTC::INFO),
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()) {
56 Athena::setOutputLevel(getMessageSvc(), m_name, m_level);
57 }
58}
59
61{
62 if (getMessageSvc()) {
63 Athena::reportMessage(getMessageSvc(), m_name, m_msgLevel, str());
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}
static const std::string levelNames[MSG::NUM_LEVELS]
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
MsgStream for TrigConf classes.
void setLevel(MSGTC::Level lvl)
Set message level of stream.
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....
IMessageSvc * getMessageSvc(bool quiet=false)
int outputLevel(const IMessageSvc *ims, const std::string &source)
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 ...
void setOutputLevel(IMessageSvc *ims, const std::string &source, int level)
Messsage levels matching the Gaudi definition.
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22