ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
GoodRunsLists
GoodRunsLists
TMsgLogger.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
* Class : TMsgLogger *
7
* *
8
* Authors (alphabetical): *
9
* Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - CERN, Switzerland *
10
**********************************************************************************/
11
12
#ifndef ROOT_Root_TMsgLogger
13
#define ROOT_Root_TMsgLogger
14
16
// //
17
// TMsgLogger //
18
// //
19
// ostreamstream derivative to redirect and format output //
20
// //
22
23
// STL include(s):
24
#include <string>
25
#include <sstream>
26
#include <map>
27
28
// ROOT include(s)
29
#include "TObject.h"
30
#include "TString.h"
31
32
// Local include(s):
33
34
namespace
Root
{
35
36
// define outside of class to facilite access
37
enum
TMsgLevel
{
38
kVERBOSE
= 1,
39
kDEBUG
= 2,
40
kINFO
= 3,
41
kWARNING
= 4,
42
kERROR
= 5,
43
kFATAL
= 6,
44
kALWAYS
= 7
45
};
46
47
class
TMsgLogger
:
public
std::ostringstream,
public
TObject {
48
49
public
:
50
51
TMsgLogger
(
const
TObject* source,
TMsgLevel
minLevel =
kINFO
);
52
TMsgLogger
(
const
std::string& source,
TMsgLevel
minLevel =
kINFO
);
53
TMsgLogger
(
TMsgLevel
minLevel =
kINFO
);
54
TMsgLogger
(
const
TMsgLogger
& parent );
55
virtual
~TMsgLogger
();
56
57
// Accessors
58
void
SetSource
(
const
char
* source ) {
m_strSource
= source; }
59
void
SetSource
(
const
std::string& source ) {
m_strSource
= source; }
60
void
SetSource
(
const
TString& source ) {
m_strSource
= source.Data(); }
61
const
std::string&
GetSource
()
const
{
return
m_strSource
; }
62
63
UInt_t
GetMaxSourceSize
()
const
{
return
(UInt_t)
m_maxSourceSize
; }
64
std::string
GetPrintedSource
()
const
;
65
std::string
GetFormattedSource
()
const
;
66
67
TMsgLevel
GetMinLevel
()
const
{
return
m_minLevel
; }
68
const
std::string&
GetMinLevelStr
()
const
{
return
m_levelMap
.find(
m_minLevel
)->second; }
69
70
TMsgLevel
MapLevel
(
const
TString& instr )
const
;
71
72
// Needed for copying
73
TMsgLogger
&
operator=
(
const
TMsgLogger
& parent );
74
75
// Stream modifier(s)
76
static
TMsgLogger
&
endmsg
(
TMsgLogger
&
logger
);
77
78
// Accept stream modifiers
79
TMsgLogger
&
operator<<
(
TMsgLogger
& ( *_f )(
TMsgLogger
& ) );
80
TMsgLogger
&
operator<<
( std::ostream& ( *_f )( std::ostream& ) );
81
TMsgLogger
&
operator<<
( std::ios& ( *_f )( std::ios& ) );
82
83
// Accept message level specification
84
TMsgLogger
&
operator<<
(
TMsgLevel
level );
85
86
// For all the "conventional" inputs
87
template
<
class
T>
TMsgLogger
&
operator<<
( T arg ) {
88
*
static_cast<
std::ostringstream*
>
(
this
) << arg;
89
return
*
this
;
90
}
91
92
static
void
SetMinLevel
(
TMsgLevel
minLevel ) {
m_minLevel
= minLevel; }
93
94
private
:
95
96
// the current minimum level is global for the whole Root
97
// it can only be changed by the central storage singleton object
98
// we make this atomic to suppress thread-checker warnings
99
static
std::atomic<TMsgLevel>
m_minLevel
;
// minimum level for logging output
100
101
// private utility routines
102
void
Send
();
103
void
InitMaps
();
104
void
WriteMsg
(
TMsgLevel
level,
const
std::string& line )
const
;
105
106
const
TObject*
m_objSource
;
// the source TObject (used for name)
107
std::string
m_strSource
;
// alternative string source
108
const
std::string
m_prefix
;
// the prefix of the source name
109
const
std::string
m_suffix
;
// suffix following source name
110
TMsgLevel
m_activeLevel
;
// active level
111
const
std::string::size_type
m_maxSourceSize
;
// maximum length of source name
112
113
std::map<TMsgLevel, std::string>
m_levelMap
;
// matches output levels with strings
114
std::map<TMsgLevel, std::string>
m_colorMap
;
// matches output levels with terminal colors
115
116
//ClassDef(TMsgLogger,0)
117
118
};
// class TMsgLogger
119
120
inline
TMsgLogger
&
TMsgLogger::operator<<
(
TMsgLogger
& (*_f)(
TMsgLogger
& ) )
121
{
122
return
(_f)(*this);
123
}
124
125
inline
TMsgLogger
&
TMsgLogger::operator<<
( std::ostream& (*_f)( std::ostream& ) )
126
{
127
(_f)(*
this
);
128
return
*
this
;
129
}
130
131
inline
TMsgLogger
&
TMsgLogger::operator<<
( std::ios& ( *_f )( std::ios& ) )
132
{
133
(_f)(*
this
);
134
return
*
this
;
135
}
136
137
inline
TMsgLogger
&
TMsgLogger::operator<<
(
TMsgLevel
level )
138
{
139
m_activeLevel
= level;
140
return
*
this
;
141
}
142
143
// Although the proper definition of "Endl" as a function pointer
144
// would be nicer C++-wise, it introduces some "unused variable"
145
// warnings so let's use the #define definition after all...
146
// [ static TMsgLogger& ( *Endl )( TMsgLogger& ) = &TMsgLogger::endmsg; ]
147
#define GEndl TMsgLogger::endmsg
148
149
}
150
151
#endif
// Root_TMsgLogger
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
Root::TMsgLogger
Definition
TMsgLogger.h:47
Root::TMsgLogger::~TMsgLogger
virtual ~TMsgLogger()
Definition
TMsgLogger.cxx:90
Root::TMsgLogger::m_minLevel
static std::atomic< TMsgLevel > m_minLevel
Definition
TMsgLogger.h:99
Root::TMsgLogger::Send
void Send()
Definition
TMsgLogger.cxx:129
Root::TMsgLogger::TMsgLogger
TMsgLogger(const TObject *source, TMsgLevel minLevel=kINFO)
Definition
TMsgLogger.cxx:42
Root::TMsgLogger::m_prefix
const std::string m_prefix
Definition
TMsgLogger.h:108
Root::TMsgLogger::GetFormattedSource
std::string GetFormattedSource() const
Definition
TMsgLogger.cxx:104
Root::TMsgLogger::MapLevel
TMsgLevel MapLevel(const TString &instr) const
Definition
TMsgLogger.cxx:195
Root::TMsgLogger::GetSource
const std::string & GetSource() const
Definition
TMsgLogger.h:61
Root::TMsgLogger::GetMinLevelStr
const std::string & GetMinLevelStr() const
Definition
TMsgLogger.h:68
Root::TMsgLogger::operator=
TMsgLogger & operator=(const TMsgLogger &parent)
Definition
TMsgLogger.cxx:93
Root::TMsgLogger::GetMaxSourceSize
UInt_t GetMaxSourceSize() const
Definition
TMsgLogger.h:63
Root::TMsgLogger::WriteMsg
void WriteMsg(TMsgLevel level, const std::string &line) const
Definition
TMsgLogger.cxx:160
Root::TMsgLogger::operator<<
TMsgLogger & operator<<(TMsgLogger &(*_f)(TMsgLogger &))
Definition
TMsgLogger.h:120
Root::TMsgLogger::m_levelMap
std::map< TMsgLevel, std::string > m_levelMap
Definition
TMsgLogger.h:113
Root::TMsgLogger::m_suffix
const std::string m_suffix
Definition
TMsgLogger.h:109
Root::TMsgLogger::SetSource
void SetSource(const TString &source)
Definition
TMsgLogger.h:60
Root::TMsgLogger::SetSource
void SetSource(const std::string &source)
Definition
TMsgLogger.h:59
Root::TMsgLogger::m_colorMap
std::map< TMsgLevel, std::string > m_colorMap
Definition
TMsgLogger.h:114
Root::TMsgLogger::SetMinLevel
static void SetMinLevel(TMsgLevel minLevel)
Definition
TMsgLogger.h:92
Root::TMsgLogger::m_objSource
const TObject * m_objSource
Definition
TMsgLogger.h:106
Root::TMsgLogger::m_strSource
std::string m_strSource
Definition
TMsgLogger.h:107
Root::TMsgLogger::GetMinLevel
TMsgLevel GetMinLevel() const
Definition
TMsgLogger.h:67
Root::TMsgLogger::GetPrintedSource
std::string GetPrintedSource() const
Definition
TMsgLogger.cxx:119
Root::TMsgLogger::InitMaps
void InitMaps()
Definition
TMsgLogger.cxx:217
Root::TMsgLogger::m_activeLevel
TMsgLevel m_activeLevel
Definition
TMsgLogger.h:110
Root::TMsgLogger::m_maxSourceSize
const std::string::size_type m_maxSourceSize
Definition
TMsgLogger.h:111
Root::TMsgLogger::SetSource
void SetSource(const char *source)
Definition
TMsgLogger.h:58
logger
static Root::TMsgLogger logger("iLumiCalc")
Root
Definition
IGoodRunsListSelectorTool.h:15
Root::TMsgLevel
TMsgLevel
Definition
TMsgLogger.h:37
Root::kALWAYS
@ kALWAYS
Definition
TMsgLogger.h:44
Root::kERROR
@ kERROR
Definition
TMsgLogger.h:42
Root::kWARNING
@ kWARNING
Definition
TMsgLogger.h:41
Root::kDEBUG
@ kDEBUG
Definition
TMsgLogger.h:39
Root::kFATAL
@ kFATAL
Definition
TMsgLogger.h:43
Root::kVERBOSE
@ kVERBOSE
Definition
TMsgLogger.h:38
Root::kINFO
@ kINFO
Definition
TMsgLogger.h:40
Generated on
for ATLAS Offline Software by
1.17.0