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

Class to provide easy MsgStream access and capabilities. More...

#include <AthenaBaseComps/AthMessaging.h>

Inherited by IDTPM::TrackMatchingLookupBase< xAOD::TrackParticle >, IDTPM::TrackMatchingLookupBase< xAOD::TrackParticle, xAOD::TruthParticle >, IDTPM::TrackMatchingLookupBase< xAOD::TruthParticle, xAOD::TrackParticle >, AFP_ToFRawData_v2, ALFA_CenterGravity, ALFA_EdgeMethod, ALFA_HalfReco, ALFA_MDGap, ALFA_MDMultiple, ALFA_MDOverlap, ALFA_MDTracking, ALFA_ODTracking, Analysis::JetTagCalibCondData, AskForRoI, AthConstConverter, Athena::LeafCnv, Athena::RootCnv, Athena::xAODCnv, AthenaEventLoopMgr, AthenaHiveEventLoopMgr, AthenaPoolConverter, AtlasDetectorID, AtlasDetectorIDHelper, CTP_Decoder, CaloGeometryFromCaloDDM, CookieCutterHelpers::CentralPosition, CrackDMConstruction, DerivationFramework::BPhysPVCascadeTools, DerivationFramework::BPhysPVTools, DetDescrConverter, EventInfoByteStreamAuxCnv, EventInfoByteStreamxAODCnv, EventInfoMuonCalibStreamCnv, ExtParameterisedVolumeBuilder, FPGATrackSimFitConstantBank, FPGATrackSimModuleRelabel, G4AtlasDetectorConstructionTool::G4AtlasDetectorConstruction, G4AtlasRunManager, G4UA::AthenaTrackingAction, G4UA::CaloG4::CalibrationDefaultProcessing, G4UA::EnergyConservationTest, G4UA::FastIDKiller, G4UA::G4AtlantisDumper, G4UA::G4CosmicAndFilter, G4UA::G4CosmicFilter, G4UA::G4CosmicOrFilter, G4UA::G4HitFilter, G4UA::G4SimTimer, G4UA::HIPKiller, G4UA::HIPLArVolumeAccept, G4UA::HitWrapper, G4UA::HyperspaceCatcher, G4UA::LooperKiller, G4UA::LooperThresholdSet, G4UA::LooperThresholdSet, G4UA::MCTruthSteppingAction, G4UA::MaterialStepRecorder, G4UA::MomentumConservation, G4UA::SG_StepNtuple, G4UA::ScoringVolumeTrackKiller, G4UA::StepHistogram, G4UA::StepNtuple, G4UA::StoppedParticleAction, G4UA::TestBoundariesUserAction, G4UA::VerboseSelector, G4UA::VolumeDebugger, G4UA::VolumeDumper, G4UA::iGeant4::PhysicsValidationUserAction, Geo2G4Builder, Geo2G4MaterialFactory, Geo2G4SolidFactory, HGTD_DetectorManager, HGTD_GmxInterface, HLT::HLTResultMTByteStreamCnv, IDPVM::ResolutionHelper, IDTPM::PlotMgr, IDTPM::TrackAnalysisCollections, IDTPM::TrackMatchingLookupBase< T, R >, IOVDbFolder, IPhysicsContructor, InDet::InDetMaterialVeto, InDet::TRT_ElectronPidTool::ToTcalculator, InDetDD::AthenaComps, InDetDD::BCMPrimeGmxInterface, InDetDD::DistortedMaterialManager, InDetDD::ExtraMaterial, InDetDD::ITk::PixelGmxInterface, InDetDD::ITk::StripGmxInterface, InDetDD::InDetDetectorManager, InDetDD::SiCommonItems, InDetDD::TRT_DetElementContainer, InDetDD::VolumeBuilder, InDetMaterialManager, InDetPlotBase, InducedChargeModel, JetTagDQA::BTaggingValidationPlots, L1TriggerResultByteStreamCnv, LArAlignHelper, LArCondFlatBase, LArCondSuperCellBase, LArFebConfig, LArG4::EC::HVHelper, LArGeo::BarrelConstruction, LArGeo::BarrelCryostatConstruction, LArGeo::EMECConstruction, LArGeo::EMECSupportConstruction, LArGeo::LArDetectorFactory, LArGeo::LArDetectorFactoryLite, LArHVIdMappingReader, LArLATOMEDecoder::EventProcess, LArMaterialManager, LArTTCellMap, LArWheelSliceSolid, LArWheelSolid, LUCID_DigitByteStreamCnv, LVL1BS::CmxCpHitsByteStreamAuxCnv, LVL1BS::CmxCpHitsByteStreamxAODCnv, LVL1BS::CmxCpTobByteStreamAuxCnv, LVL1BS::CmxCpTobByteStreamxAODCnv, LVL1BS::CmxEtSumsByteStreamAuxCnv, LVL1BS::CmxEtSumsByteStreamxAODCnv, LVL1BS::CmxJetHitsByteStreamAuxCnv, LVL1BS::CmxJetHitsByteStreamxAODCnv, LVL1BS::CmxJetTobByteStreamAuxCnv, LVL1BS::CmxJetTobByteStreamxAODCnv, LVL1BS::CmxRoIByteStreamAuxCnv, LVL1BS::CmxRoIByteStreamxAODCnv, LVL1BS::CpmTobRoiByteStreamAuxCnv, LVL1BS::CpmTobRoiByteStreamxAODCnv, LVL1BS::CpmTowerByteStreamAuxCnv, LVL1BS::CpmTowerByteStreamxAODCnv, LVL1BS::JemEtSumsByteStreamAuxCnv, LVL1BS::JemEtSumsByteStreamxAODCnv, LVL1BS::JemTobRoiByteStreamAuxCnv, LVL1BS::JemTobRoiByteStreamxAODCnv, LVL1BS::JetElementByteStreamAuxCnv, LVL1BS::JetElementByteStreamxAODCnv, LVL1BS::L1CaloByteStreamAuxCnv< ContainerT, AuxContainerT >, LVL1BS::L1TopoByteStreamAuxCnv, LVL1BS::L1TopoByteStreamxAODCnv, LVL1BS::PpmByteStreamAuxCnv, LVL1BS::PpmByteStreamxAODCnv, LVL1BS::RodHeaderByteStreamAuxCnv, LVL1BS::RodHeaderByteStreamxAODCnv, LVL1TGC::TGCBIS78, LVL1TGC::TGCBIS78CoincidenceMap, LVL1TGC::TGCEIFICoincidenceMap, LVL1TGC::TGCGoodMF, LVL1TGC::TGCNSW, LVL1TGC::TGCTMDB, LVL1TGCTrigger::TGCDatabaseManager, LVL1TGCTrigger::TGCNSWCoincidenceMap, MMLoadVariables, MMT_Diamond, MM_StripsResponseSimulation, McVtxFilter, Muon::DigitEffiData, Muon::STgcClusterBuilderCommon, Muon::TgcSlbDataHelper, Muon::TwinTubeMap, Muon::mmCTPClusterCalibData, MuonCalib::CalibT0DbOperations, MuonG4R4::MuonSensitiveDetector, MuonGM::MYSQL, MuonGM::MuonChamber, MuonGM::MuonChamberLite, MuonGM::MuonDetectorManager, MuonGM::MuonPadDesign, MuonGM::MuonReadoutElement, MuonGM::MuonStation, MuonGM::RDBReaderAtlas, MuonGM::Station, MuonGM::TgcReadoutParams, MuonGMR4::MuonDetectorManager, MuonGMR4::MuonReadoutElement, MuonGMR4::SpectrometerSector, MuonGMR4::StripDesign, MuonHoughHisto2D, MuonHoughTransformSteering, MuonHoughTransformer, MuonR4::MsTrackSeeder, MuonR4::SegmentFit::MdtSegmentSeedGenerator, MuonR4::SegmentFit::SegmentAmbiSolver, MuonR4::SegmentFit::SegmentLineFitter, MuonVal::IParticleFourMomBranch, MuonVal::MuonTesterBranch, MuonVal::MuonTesterTree, NswCalibDbTimeChargeData, NswErrorCalibData, ParticleCandidateList, PileUpEventLoopMgr, PileUpStream, PixelGeoDC2::PixelGeometryManager, RDBMaterialManager, RatesHistoBase, Ringer::BuildCaloRingsFctorBase, Ringer::BuildCaloRingsJetFctorBase, RoIBResultByteStreamCnv< ROBF >, RootAuxDynIO::RNTupleAuxDynReader, RootAuxDynIO::RNTupleAuxDynWriter, RootAuxDynIO::TBranchAuxDynWriter, Routing2, SCT_ReadoutData, ServicesTracker, SingleLogicalVolumeFactory, SqliteRecordset, TCCPlotsBase, TGCTriggerBWCWReader, TRRegionXMLHandler, TRTDigCondBase, TRTDigSettings, TRTElectronicsProcessing, TRTNoise, TRTProcessingOfStraw, TRTTimeCorrection, TRTTransitionRadiation, TRT_PAI_effectiveGas, TRT_PAI_gasMixture, TgcDigitJitterData, TgcDigitMaker, TgcDigitThresholdData, TileCellDim, TileCorrelation, TileDddbManager, TileDetDescrManager, TilePulseShape, TileROD_Encoder, TrackFitter, TrigCostAuditor, TrigSORFromPtreeHelper, Trk::AlignModule, Trk::GeoShapeConverter, Trk::VolumeConverter, VolumeTreeNavigator, ZDC_DetFactory, ZDC_DetManager, ZdcLucrodDecoder, asg::AsgMessaging, pool::APRMessaging, pool::DbSessionObj, pool::DbStorageExplorer, pool::IFileCatalog, sTGCAsBuiltData, sTGCSensitiveDetector, sTgcDigitMaker, and sTgcDigitMaker.

Collaboration diagram for AthMessaging:

Public Member Functions

 AthMessaging (IMessageSvc *msgSvc, const std::string &name)
 Constructor.
 AthMessaging (const std::string &name)
 Constructor with auto-retrieval of the MessageSvc.
virtual ~AthMessaging ()
 Destructor:
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

 AthMessaging ()
 Default constructor:
 AthMessaging (const AthMessaging &rhs)
AthMessagingoperator= (const AthMessaging &rhs)
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Class to provide easy MsgStream access and capabilities.

All the expensive operations (e.g. retrieval of MessageSvc) are done lazily, i.e. only when a message is printed to keep the construction of this class as fast as possible.

One usually inherits from this class and uses it like so:

class MyClass : public AthMessaging, ... {
public:
MyClass() : AthMessaging("MyName") {}
void print() {
ATH_MSG_INFO("Hello World");
}
};
#define ATH_MSG_INFO(x)
void print(char *figname, TCanvas *c1)
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.

The above will retrieve the pointer to the MessageSvc when needed. If you have access to it already, it is preferred to pass it explicitly:

MyClass() : AthMessaging(msgSvc, "MyName") {}

Definition at line 54 of file AthMessaging.h.

Constructor & Destructor Documentation

◆ AthMessaging() [1/4]

AthMessaging::AthMessaging ( IMessageSvc * msgSvc,
const std::string & name )

Constructor.

Parameters
msgSvcPointer to the MessageSvc
nameName of the message stream

Definition at line 13 of file AthMessaging.cxx.

14 :
15 m_nm(name), m_imsg(msgSvc)
16{}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.

◆ AthMessaging() [2/4]

AthMessaging::AthMessaging ( const std::string & name)

Constructor with auto-retrieval of the MessageSvc.

Parameters
nameName of the message stream

Definition at line 19 of file AthMessaging.cxx.

19 :
20 m_nm(name)
21{}

◆ ~AthMessaging()

AthMessaging::~AthMessaging ( )
virtual

Destructor:

Definition at line 24 of file AthMessaging.cxx.

25{}

◆ AthMessaging() [3/4]

AthMessaging::AthMessaging ( )
private

Default constructor:

◆ AthMessaging() [4/4]

AthMessaging::AthMessaging ( const AthMessaging & rhs)
private

Member Function Documentation

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
private

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inline

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inline

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inline

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ operator=()

AthMessaging & AthMessaging::operator= ( const AthMessaging & rhs)
private

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivate

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivate

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivate

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivate

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

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
private

Message source name.

Definition at line 129 of file AthMessaging.h.


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