ATLAS Offline Software
Loading...
Searching...
No Matches
MLogging Class Reference

Cut down AthMessaging. More...

#include <MLogging.h>

Inherited by ISF_FCS_Parametrization::FCS_StepInfo, TFCSExtrapolationState, TFCSFunction, TFCSGANEtaSlice, TFCSGANXMLParameters, TFCSMLCalorimeterSimulator, TFCSParametrizationBase, TFCSSimulationState, TFCSTruthState, and VNetworkBase.

Collaboration diagram for MLogging:

Public Member Functions

 MLogging (const std::string &name="ISF_FastCaloSimEvent")
 Constructor.
 MLogging (const MLogging &rhs)
 Copy constructor and assignment operator.
MLoggingoperator= (const MLogging &rhs)
virtual ~MLogging ()
 Destructor:
bool msgLvl (const MSG::Level lvl) const
 Check whether the logging system is active at the provided verbosity level.
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration)
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages.
MSG::Level level () const
 Retrieve output level.
virtual void setLevel (MSG::Level lvl)
 Update outputlevel.

Static Public Member Functions

static std::string startMsg (MSG::Level lvl, const std::string &file, int line)
 Make a message to decorate the start of logging.

Private Attributes

std::string m_nm
 Message source name.

Static Private Attributes

static boost::thread_specific_ptr< MsgStream > m_msg_tls ATLAS_THREAD_SAFE
 Do not persistify!

Detailed Description

Cut down AthMessaging.

Definition at line 176 of file MLogging.h.

Constructor & Destructor Documentation

◆ MLogging() [1/2]

ISF_FCS::MLogging::MLogging ( const std::string & name = "ISF_FastCaloSimEvent")

Constructor.

Definition at line 91 of file MLogging.cxx.

91: m_nm(name) {}
std::string m_nm
Message source name.
Definition MLogging.h:211

◆ MLogging() [2/2]

ISF_FCS::MLogging::MLogging ( const MLogging & rhs)

Copy constructor and assignment operator.

Definition at line 95 of file MLogging.cxx.

95 : m_nm(rhs.m_nm) {
96 this->setLevel(rhs.level());
97};
virtual void setLevel(MSG::Level lvl)
Update outputlevel.
Definition MLogging.cxx:105
MSG::Level level() const
Retrieve output level.
Definition MLogging.h:201

◆ ~MLogging()

ISF_FCS::MLogging::~MLogging ( )
virtual

Destructor:

Definition at line 93 of file MLogging.cxx.

93{}

Member Function Documentation

◆ level()

MSG::Level ISF_FCS::MLogging::level ( ) const
inline

Retrieve output level.

Definition at line 201 of file MLogging.h.

201{ return msg().level(); }
MsgStream & msg() const
Return a stream for sending messages directly (no decoration)
Definition MLogging.h:231

◆ msg() [1/2]

MsgStream & ISF_FCS::MLogging::msg ( ) const
inline

Return a stream for sending messages directly (no decoration)

Definition at line 231 of file MLogging.h.

231 {
232 MsgStream *ms = m_msg_tls.get();
233 if (!ms) {
234 ms = new MsgStream(Athena::getMessageSvc(), m_nm);
235 m_msg_tls.reset(ms);
236 }
237 return *ms;
238}
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [2/2]

MsgStream & ISF_FCS::MLogging::msg ( const MSG::Level lvl) const
inline

Return a decorated starting stream for sending messages.

Definition at line 240 of file MLogging.h.

240 {
241 return msg() << lvl;
242}

◆ msgLvl()

bool ISF_FCS::MLogging::msgLvl ( const MSG::Level lvl) const
inline

Check whether the logging system is active at the provided verbosity level.

Definition at line 222 of file MLogging.h.

222 {
223 if (msg().level() <= lvl) {
224 msg() << lvl;
225 return true;
226 } else {
227 return false;
228 }
229}

◆ operator=()

MLogging & ISF_FCS::MLogging::operator= ( const MLogging & rhs)

Definition at line 99 of file MLogging.cxx.

99 {
100 this->m_nm = rhs.m_nm;
101 this->setLevel(rhs.level());
102 return *this;
103}

◆ setLevel()

void ISF_FCS::MLogging::setLevel ( MSG::Level lvl)
virtual

Update outputlevel.

Definition at line 105 of file MLogging.cxx.

105 {
106 lvl = (lvl >= MSG::NUM_LEVELS) ? MSG::ALWAYS
107 : (lvl < MSG::NIL) ? MSG::NIL
108 : lvl;
109 msg().setLevel(lvl);
110}

◆ startMsg()

std::string ISF_FCS::MLogging::startMsg ( MSG::Level lvl,
const std::string & file,
int line )
static

Make a message to decorate the start of logging.

Print a message for the start of logging.

Definition at line 116 of file MLogging.cxx.

116 {
117 int col1_len = 20;
118 int col2_len = 5;
119 int col3_len = 10;
120 auto last_slash = file.find_last_of('/');
121 int path_len = last_slash == std::string::npos ? 0 : last_slash;
122 int trim_point = path_len;
123 int total_len = file.length();
124 if (total_len - path_len > col1_len)
125 trim_point = total_len - col1_len;
126 std::string trimmed_name = file.substr(trim_point);
127 const char *LevelNames[MSG::NUM_LEVELS] = {
128 "NIL", "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "ALWAYS"};
129 std::string level = LevelNames[lvl];
130 std::string level_string = std::string("(") + level + ") ";
131 std::stringstream output;
132 output << std::setw(col1_len) << std::right << trimmed_name << ":"
133 << std::setw(col2_len) << std::left << line << std::setw(col3_len)
134 << std::right << level_string;
135 return output.str();
136}
output
Definition merge.py:16
TFile * file

Member Data Documentation

◆ ATLAS_THREAD_SAFE

boost::thread_specific_ptr<MsgStream> m_msg_tls ISF_FCS::MLogging::ATLAS_THREAD_SAFE
inlinestaticprivate

Do not persistify!

MsgStream instance (a std::cout like with print-out levels)

Definition at line 215 of file MLogging.h.

◆ m_nm

std::string ISF_FCS::MLogging::m_nm
private

Message source name.

Definition at line 211 of file MLogging.h.


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