ATLAS Offline Software
DbPrint.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //====================================================================
6 // APR Printer object
7 //--------------------------------------------------------------------
8 
9 #ifndef POOL_DBPRINT_H
10 #define POOL_DBPRINT_H 1
11 
12 #include <atomic>
15 #include "SystemTools.h"
16 
17 namespace pool {
18 
19  struct DbPrintLvl {
21  static const MsgLevel None = MsgLevel::NIL;
23  static const MsgLevel Debug = MsgLevel::DEBUG;
24  static const MsgLevel Info = MsgLevel::INFO;
26  static const MsgLevel Error = MsgLevel::ERROR;
27  static const MsgLevel Fatal = MsgLevel::FATAL;
29 
30  static std::atomic<MsgLevel> outputLvl;
31  inline static void setLevel( MsgLevel l ) { outputLvl=l; }
32  };
33 
34 
35  class DbPrint : public MsgStream
36  {
37  public:
38  DbPrint( const std::string& name )
39  // 'quiet=true' option only works with 'Eager' creation
40  : MsgStream( Athena::getMessageSvc(Athena::Options::Eager,true), name )
41  {
43  setLevel( DbPrintLvl::outputLvl );
44  }
45  }
46 
47  static MsgStream& endmsg( MsgStream& s ) { return ::endmsg(s); }
48  };
49 
51  class APRMessaging : public AthMessaging {
52  public:
53  APRMessaging(const std::string& name) : AthMessaging(name) {
54  auto lvl = SystemTools::GetOutputLvl();
55  // an output line needed to initialize AthMessaging or setLevel will not work
56  ATH_MSG_VERBOSE("Setting the loglevel to " << (int) lvl );
57  setLevel( lvl );
58  }
59 
60  APRMessaging(const APRMessaging&) = delete;
61  APRMessaging& operator=(const APRMessaging&) = delete;
64  };
65 
66 } // End namespace pool
67 #endif // POOL_DBPRINT_H
pool::DbPrintLvl::Fatal
static const MsgLevel Fatal
Definition: DbPrint.h:27
pool::APRMessaging::APRMessaging
APRMessaging(const std::string &name)
Definition: DbPrint.h:53
pool::DbPrint
Definition: DbPrint.h:36
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:18
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
pool::DbPrintLvl
Definition: DbPrint.h:19
pool::DbPrintLvl::None
static const MsgLevel None
Definition: DbPrint.h:21
pool
pool namespace
Definition: libname.h:15
python.Constants.ERROR
int ERROR
Definition: Control/AthenaCommon/python/Constants.py:17
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
pool::APRMessaging
AthMessaging wrapper to set the output level in APR components.
Definition: DbPrint.h:51
pool::SystemTools::GetOutputLvl
static MSG::Level GetOutputLvl()
pool::DbPrint::endmsg
static MsgStream & endmsg(MsgStream &s)
Definition: DbPrint.h:47
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
pool::DbPrintLvl::MsgLevel
MSG::Level MsgLevel
Definition: DbPrint.h:20
AthMessaging::setLevel
void setLevel(MSG::Level lvl)
Change the current logging level.
Definition: AthMessaging.cxx:28
pool::DbPrintLvl::setLevel
static void setLevel(MsgLevel l)
Definition: DbPrint.h:31
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
pool::APRMessaging::operator=
APRMessaging & operator=(APRMessaging &&)=delete
pool::APRMessaging::APRMessaging
APRMessaging(const APRMessaging &)=delete
TrigConf::MSGTC::ALWAYS
@ ALWAYS
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:29
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
pool::DbPrintLvl::outputLvl
static std::atomic< MsgLevel > outputLvl
Definition: DbPrint.h:30
python.Constants.WARNING
int WARNING
Definition: Control/AthenaCommon/python/Constants.py:16
pool::APRMessaging::operator=
APRMessaging & operator=(const APRMessaging &)=delete
pool::APRMessaging::APRMessaging
APRMessaging(APRMessaging &&)=delete
pool::DbPrintLvl::Error
static const MsgLevel Error
Definition: DbPrint.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
checkNSWValTree.Options
Options
Definition: checkNSWValTree.py:14
pool::DbPrintLvl::Info
static const MsgLevel Info
Definition: DbPrint.h:24
SystemTools.h
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
pool::DbPrintLvl::Always
static const MsgLevel Always
Definition: DbPrint.h:28
DEBUG
#define DEBUG
Definition: page_access.h:11
AthMessaging.h
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
pool::DbPrintLvl::Verbose
static const MsgLevel Verbose
Definition: DbPrint.h:22
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
TrigConf::MSGTC::NIL
@ NIL
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:22
pool::DbPrintLvl::Warning
static const MsgLevel Warning
Definition: DbPrint.h:25
pool::DbPrint::DbPrint
DbPrint(const std::string &name)
Definition: DbPrint.h:38
pool::DbPrintLvl::Debug
static const MsgLevel Debug
Definition: DbPrint.h:23