ATLAS Offline Software
Control/AthToolSupport/AsgMessaging/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 // System include(s):
6 #include <string>
7 #include <iostream>
8 #include <iomanip>
9 
10 // Local include(s):
11 #include "AsgMessaging/MsgStream.h"
14 
15 MsgStream::MsgStream( const INamedInterface* tool )
16  : m_tool( tool ), m_name( "" ),
17  m_lvl( MSG::INFO ), m_reqlvl( MSG::NIL ) {
18 
19 }
20 
21 MsgStream::MsgStream( const std::string& name )
22  : m_tool( 0 ), m_name( name ),
23  m_lvl( MSG::INFO ), m_reqlvl( MSG::NIL ) {
24 
25 }
26 
37 MsgStream::MsgStream( void*, const std::string& name, int )
38  : MsgStream( name ) {
39 
40 }
41 
42 MsgStream& MsgStream::operator<< ( MsgStream& ( *_f )( MsgStream& ) ) {
43 
44  return ( _f )( *this );
45 }
46 
47 MsgStream& MsgStream::operator<< ( std::ostream& ( *_f )( std::ostream& ) ) {
48 
49  ( _f )( *this );
50  return *this;
51 }
52 
53 MsgStream& MsgStream::operator<< ( std::ios& ( *_f )( std::ios& ) ) {
54 
55  ( _f )( *this );
56  return *this;
57 }
58 
59 MsgStream& MsgStream::operator<< ( MSG::Level lvl ) {
60 
61  m_reqlvl = lvl;
62  return *this;
63 }
64 
71 MsgStream& MsgStream::doOutput() {
72 
73  // Check if anything needs to be printed:
74  if( m_reqlvl >= m_lvl ) {
76  .print (m_reqlvl, name(), this->str());
77  }
78 
79  // Reset the stream buffer:
80  this->str( "" );
81 
82  return *this;
83 }
84 
85 void MsgStream::setLevel( MSG::Level lvl ) {
86 
87  m_lvl = lvl;
88  return;
89 }
90 
91 bool MsgStream::msgLevel( MSG::Level lvl ) const {
92 
93  return ( lvl >= m_lvl );
94 }
95 
97 
98  return MSG::Level (m_lvl);
99 }
100 
101 MSG::Level MsgStream::currentLevel() const {
102 
103  return m_reqlvl;
104 }
105 
106 const std::string& MsgStream::name() const {
107 
108  // If we have a valid tool parent:
109  if( m_tool ) {
110  return m_tool->name();
111  }
112 
113  // If not, return the name stored in the object:
114  return m_name;
115 }
116 
117 void MsgStream::setName( const std::string& name ) {
118 
119  // Detach the object from the IAsgTool pointer:
120  m_tool = 0;
121 
122  // Remember this name:
123  m_name = name;
124 
125  return;
126 }
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
pool::DbPrintLvl::setLevel
void setLevel(MsgLevel l)
Definition: DbPrint.h:32
MessagePrinterOverlay.h
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
asg::MessagePrinterOverlay::current
static IMessagePrinter & current() noexcept
get the current IMessagePrinter
Definition: MessagePrinterOverlay.cxx:57
MSG
Definition: MsgLevel.h:28
MSG::name
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition: MsgLevel.cxx:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
IMessagePrinter.h
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:16
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
MsgStream.h