The Gaudi Framework  v29r0 (ff2e7097)
IssueLogger Class Reference

#include <src/IssueLogger.h>

Inheritance diagram for IssueLogger:
Collaboration diagram for IssueLogger:

Classes

class  logger_t
 

Public Member Functions

 IssueLogger (const std::string &name, ISvcLocator *svc)
 
 ~IssueLogger () override=default
 
StatusCode initialize () override
 
StatusCode reinitialize () override
 
StatusCode finalize () override
 
void report (IssueSeverity::Level level, const std::string &msg, const std::string &origin) override
 
void report (const IssueSeverity &err) override
 
- Public Member Functions inherited from extends< Service, IIssueLogger >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Member Functions

StatusCode connect (const std::string &)
 
void setupDefaultLogger ()
 
void setupLevels (Gaudi::Details::PropertyBase &prop)
 
void setupStreams (Gaudi::Details::PropertyBase &prop)
 

Private Attributes

Gaudi::Property< std::vector< std::string > > m_outputfile {this, "Output"}
 
Gaudi::Property< std::stringm_reportLevelS {this, "ReportLevel", "WARNING"}
 
Gaudi::Property< std::stringm_traceLevelS {this, "TracebackLevel", "ERROR"}
 
Gaudi::Property< bool > m_showTime {this, "ShowTime", false}
 
IssueSeverity::Level m_reportLevel
 
IssueSeverity::Level m_traceLevel
 
std::array< logger_t, IssueSeverity::NUM_LEVELSm_log
 

Additional Inherited Members

- Public Types inherited from extends< Service, IIssueLogger >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Detailed Description

Definition at line 13 of file IssueLogger.h.

Constructor & Destructor Documentation

IssueLogger::IssueLogger ( const std::string name,
ISvcLocator svc 
)

Definition at line 54 of file IssueLogger.cpp.

54  : base_class( name, svc )
55 {
56 
57  m_reportLevelS.declareUpdateHandler( &IssueLogger::setupLevels, this );
58  m_traceLevelS.declareUpdateHandler( &IssueLogger::setupLevels, this );
59  m_outputfile.declareUpdateHandler( &IssueLogger::setupStreams, this );
60 
63 }
void setupStreams(Gaudi::Details::PropertyBase &prop)
void setupLevels(Gaudi::Details::PropertyBase &prop)
extends base_class
Typedef to this class.
Definition: extends.h:15
IssueSeverity::Level m_reportLevel
Definition: IssueLogger.h:32
Gaudi::Property< std::vector< std::string > > m_outputfile
Definition: IssueLogger.h:27
Gaudi::Property< std::string > m_traceLevelS
Definition: IssueLogger.h:29
IssueSeverity::Level m_traceLevel
Definition: IssueLogger.h:32
Gaudi::Property< std::string > m_reportLevelS
Definition: IssueLogger.h:28
IssueLogger::~IssueLogger ( )
overridedefault

Member Function Documentation

StatusCode IssueLogger::connect ( const std::string ident)
private

Definition at line 98 of file IssueLogger.cpp.

99 {
100 
101  auto loc = ident.find( " " );
102  using Parser = Gaudi::Utils::AttribStringParser;
103  // note: if loc == string::npos then loc + 1 == 0
104  for ( auto attrib : Parser( ident.substr( loc + 1 ) ) ) {
105  toupper( attrib.tag );
107  if ( attrib.tag == "DEBUG" ) {
108  level = IssueSeverity::DEBUG;
109  } else if ( attrib.tag == "INFO" ) {
110  level = IssueSeverity::INFO;
111  } else if ( attrib.tag == "WARNING" ) {
112  level = IssueSeverity::WARNING;
113  } else if ( attrib.tag == "RECOVERABLE" ) {
115  } else if ( attrib.tag == "ERROR" ) {
116  level = IssueSeverity::ERROR;
117  } else if ( attrib.tag == "FATAL" ) {
118  level = IssueSeverity::FATAL;
119  } else {
120  error() << "Unknown output level \"" << attrib.tag << "\"" << endmsg;
121  continue;
122  }
123 
124  if ( m_log[level] ) {
125  info() << "closing stream " << m_log[level].name() << endmsg;
126  m_log[level].reset();
127  }
128 
129  if ( attrib.value == "MsgSvc" ) {
130  m_log[level] = {new StreamLogger( msgSvc(), s_sevMsgMap.at( level ) ), &StreamLogger::WriteToMsgSvc};
131  } else if ( attrib.value == "STDERR" ) {
133  } else if ( attrib.value == "STDOUT" ) {
135  } else { // A file
136  try {
137  m_log[level] = {new StreamLogger( attrib.value ), &StreamLogger::WriteToStream};
138  } catch ( std::exception& ) {
139  m_log[level].reset();
140  error() << "Unable to open file \"" << attrib.value << "\" for writing issues at level " << attrib.tag
141  << endmsg;
142  return StatusCode::FAILURE;
143  }
144  }
145  debug() << "Writing " << s_levelTrans.at( level ) << " issues to " << m_log[level].name() << endmsg;
146  }
147  return StatusCode::SUCCESS;
148 }
Parse attribute strings allowing iteration over the various attributes.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
void toupper(std::string &s)
Definition: IssueLogger.cpp:50
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
STL class.
T find(T...args)
std::array< logger_t, IssueSeverity::NUM_LEVELS > m_log
Definition: IssueLogger.h:49
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
T substr(T...args)
void WriteToMsgSvc(const std::string &str)
Definition: StreamLogger.h:21
void WriteToStream(const std::string &str)
Definition: StreamLogger.h:20
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode IssueLogger::finalize ( )
override

Definition at line 88 of file IssueLogger.cpp.

89 {
90 
91  debug() << "IssueLogger::finalize" << endmsg;
92  std::for_each( std::begin( m_log ), std::end( m_log ), []( logger_t& i ) { i.reset(); } );
93  return Service::finalize();
94 }
StatusCode finalize() override
Definition: Service.cpp:174
T end(T...args)
std::array< logger_t, IssueSeverity::NUM_LEVELS > m_log
Definition: IssueLogger.h:49
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T begin(T...args)
T for_each(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode IssueLogger::initialize ( )
override

Definition at line 67 of file IssueLogger.cpp.

68 {
69 
71  if ( st.isSuccess() ) {
73  }
74  return st;
75 }
StatusCode initialize() override
Definition: Service.cpp:64
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
void setupDefaultLogger()
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
StatusCode IssueLogger::reinitialize ( )
override

Definition at line 79 of file IssueLogger.cpp.

80 {
81 
82  warning() << "reinitialize not implemented" << endmsg;
83  return StatusCode::SUCCESS;
84 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void IssueLogger::report ( IssueSeverity::Level  level,
const std::string msg,
const std::string origin 
)
override

Definition at line 152 of file IssueLogger.cpp.

153 {
154  if ( lev < m_reportLevel ) return;
155  std::string msg = s_levelTrans.at( lev ) + " " + org + " \"" + str + "\"";
156  if ( m_showTime ) msg += " [" + Gaudi::Time::current().format( true, "%H:%M:%S %Y/%m/%d %Z" ) + "]";
157  if ( lev >= m_traceLevel ) msg += "\n" + getTraceBack();
158  m_log[lev]( msg );
159 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
static Time current()
Returns the current time.
Definition: Time.cpp:112
IssueSeverity::Level m_reportLevel
Definition: IssueLogger.h:32
STL class.
T at(T...args)
Gaudi::Property< bool > m_showTime
Definition: IssueLogger.h:30
std::array< logger_t, IssueSeverity::NUM_LEVELS > m_log
Definition: IssueLogger.h:49
IssueSeverity::Level m_traceLevel
Definition: IssueLogger.h:32
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
Definition: Time.cpp:260
void IssueLogger::report ( const IssueSeverity err)
override

Definition at line 163 of file IssueLogger.cpp.

163 { report( err.getLevel(), err.getMsg(), err.getOrigin() ); }
std::string getOrigin() const
IssueSeverity::Level getLevel() const
Definition: IssueSeverity.h:57
std::string getMsg() const
Definition: IssueSeverity.h:58
void report(IssueSeverity::Level level, const std::string &msg, const std::string &origin) override
void IssueLogger::setupDefaultLogger ( )
private

Definition at line 217 of file IssueLogger.cpp.

218 {
219  for ( int i = 1; i < IssueSeverity::NUM_LEVELS; ++i ) {
220  if ( !m_log[i] ) {
221  // default: dump to msgSvc
223  m_log[j] = {new StreamLogger( msgSvc(), s_sevMsgMap.at( j ) ), &StreamLogger::WriteToMsgSvc};
224  debug() << "Writing " << s_levelTrans.at( j ) << " issues to " << m_log[j].name() << endmsg;
225  }
226  }
227 }
std::array< logger_t, IssueSeverity::NUM_LEVELS > m_log
Definition: IssueLogger.h:49
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
void WriteToMsgSvc(const std::string &str)
Definition: StreamLogger.h:21
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void IssueLogger::setupLevels ( Gaudi::Details::PropertyBase prop)
private

Definition at line 167 of file IssueLogger.cpp.

168 {
169 
170  Gaudi::Property<std::string>* sap = dynamic_cast<Gaudi::Property<std::string>*>( &prop );
171  if ( !sap ) {
172  error() << "Could not convert " << prop.name() << "to a Gaudi::Property<std::string> (which it should be!)"
173  << endmsg;
174  return;
175  }
176 
177  const std::string& val = sap->value();
178  auto set = [&]( IssueSeverity::Level& key, IssueSeverity::Level def ) {
179  if ( s_levelSTrans.find( val ) == s_levelSTrans.end() ) {
180  key = def;
181  error() << "Option " << prop.name() << ": unknown Issue Severity level \"" << val << "\". Setting it "
182  << s_levelTrans.at( def ) << endmsg;
183  } else {
184  key = s_levelSTrans.at( val );
185  }
186  };
187 
188  if ( prop.name() == "ReportLevel" ) {
190  } else if ( prop.name() == "TracebackLevel" ) {
192  } else {
193  error() << "setting up unknown property \"" << prop.name() << "\"" << endmsg;
194  }
195 }
Implementation of property with value of concrete type.
Definition: Property.h:319
const std::string name() const
property name
Definition: Property.h:40
IssueSeverity::Level m_reportLevel
Definition: IssueLogger.h:32
STL class.
T at(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:479
IssueSeverity::Level m_traceLevel
Definition: IssueLogger.h:32
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void IssueLogger::setupStreams ( Gaudi::Details::PropertyBase prop)
private

Definition at line 199 of file IssueLogger.cpp.

200 {
201 
203  if ( !sap ) {
204  error() << "Could not convert " << prop.name()
205  << "to a Gaudi::Property<std::vector<std::string>> (which it should be!)" << endmsg;
206  return;
207  }
208  for ( const auto& s : sap->value() ) {
209  if ( connect( s ).isFailure() ) {
210  error() << "Could not setup stream " << s << endmsg;
211  }
212  }
213 }
StatusCode connect(const std::string &)
Definition: IssueLogger.cpp:98
Implementation of property with value of concrete type.
Definition: Property.h:319
const std::string name() const
property name
Definition: Property.h:40
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
string s
Definition: gaudirun.py:253
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:479
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

Member Data Documentation

std::array<logger_t, IssueSeverity::NUM_LEVELS> IssueLogger::m_log
private

Definition at line 49 of file IssueLogger.h.

Gaudi::Property<std::vector<std::string> > IssueLogger::m_outputfile {this, "Output"}
private

Definition at line 27 of file IssueLogger.h.

IssueSeverity::Level IssueLogger::m_reportLevel
private

Definition at line 32 of file IssueLogger.h.

Gaudi::Property<std::string> IssueLogger::m_reportLevelS {this, "ReportLevel", "WARNING"}
private

Definition at line 28 of file IssueLogger.h.

Gaudi::Property<bool> IssueLogger::m_showTime {this, "ShowTime", false}
private

Definition at line 30 of file IssueLogger.h.

IssueSeverity::Level IssueLogger::m_traceLevel
private

Definition at line 32 of file IssueLogger.h.

Gaudi::Property<std::string> IssueLogger::m_traceLevelS {this, "TracebackLevel", "ERROR"}
private

Definition at line 29 of file IssueLogger.h.


The documentation for this class was generated from the following files: