ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1Base
src
VP1Msg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Implementation of class VP1Msg //
9
// //
10
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11
// Initial version: March 2008 //
12
// //
14
15
#include "
VP1Base/VP1Msg.h
"
16
#include "
VP1Base/IVP1System.h
"
17
#include "
VP1Base/VP1QtUtils.h
"
18
#include <iostream>
19
20
#ifndef BUILDVP1LIGHT
//TODO: Merge the two mechanisms, specifically for VP1
21
std::atomic<bool>
VP1Msg::m_verbose
=
VP1QtUtils::environmentVariableIsOn
(
"VP1_VERBOSE_OUTPUT"
);
22
std::atomic<bool>
VP1Msg::m_debug
=
VP1QtUtils::environmentVariableIsOn
(
"VP1_DEBUG_OUTPUT"
);
23
#endif
24
#ifdef BUILDVP1LIGHT
25
std::atomic<bool>
VP1Msg::m_verbose
=
VP1QtUtils::expertSettingIsSet
(
"general"
,
"ExpertSettings/VP1_VERBOSE_OUTPUT"
);
26
std::atomic<bool>
VP1Msg::m_debug
=
VP1QtUtils::expertSettingIsSet
(
"general"
,
"ExpertSettings/VP1_DEBUG_OUTPUT"
);
27
#endif
28
29
//____________________________________________________________________
30
void
VP1Msg::message
(
const
QString&
str
,
IVP1System
*sys )
31
{
32
if
(sys)
33
sys->message(
str
);
34
else
35
std::cout <<
prefix_msg
() <<
": "
<<
str
.toStdString()<<std::endl;
36
}
37
38
//____________________________________________________________________
39
void
VP1Msg::messageDebug
(
const
QString&
str
)
40
{
41
if
(!
debug
()){
42
return
;
43
}
44
std::cout <<
prefix_debug
() <<
": "
<<
str
.toStdString()<<std::endl;
45
}
46
47
//____________________________________________________________________
48
void
VP1Msg::messageWarning
(
const
QString&
str
,
IVP1System
* sys
/* defaults to: 0 */
)
49
{
50
if
(sys)
51
sys->message(
str
);
52
std::cout <<
prefix_warning
() <<
": "
<<
str
.toStdString()<<std::endl;
53
}
54
55
// only the 'Warning' label is printed in red
56
//____________________________________________________________________
57
void
VP1Msg::messageWarningRed
(
const
QString&
str
,
IVP1System
* sys
/* defaults to: 0 */
)
58
{
59
if
(sys)
60
sys->message(
str
);
61
62
// colors, see:
63
// - http://brianmilco.blogspot.ch/2011/11/color-debug-output-with-qt-and-qdebug.html
64
// - http://misc.flogisoft.com/bash/tip_colors_and_formatting
65
std::string
msg
=
str
.toStdString();
66
fprintf(stderr,
"\033[1m\033[31mWarning:\033[21m\033[0m: %s\n"
,
msg
.c_str() );
67
}
68
// The whole 'Warning' message is printed in red
69
//____________________________________________________________________
70
void
VP1Msg::messageWarningAllRed
(
const
QString&
str
,
IVP1System
* sys
/* defaults to: 0 */
)
71
{
72
if
(sys)
73
sys->message(
str
);
74
75
// colors, see:
76
// - http://brianmilco.blogspot.ch/2011/11/color-debug-output-with-qt-and-qdebug.html
77
// - http://misc.flogisoft.com/bash/tip_colors_and_formatting
78
std::string
msg
=
str
.toStdString();
79
fprintf(stderr,
"\033[1m\033[31mWarning:\033[21m %s\033[0m\n"
,
msg
.c_str() );
80
}
81
82
83
//____________________________________________________________________
84
void
VP1Msg::messageVerbose
(
const
QString&
str
)
85
{
86
if
(!
verbose
()){
87
return
;
88
}
89
std::cout<<
prefix_verbose
()<<
": "
<<
str
.toStdString()<<std::endl;
90
}
91
92
//____________________________________________________________________
93
void
VP1Msg::message
(
const
QStringList& l,
const
QString& addtoend,
IVP1System
*sys )
94
{
95
if
(addtoend.isEmpty()) {
96
for
(
const
QString& s : l)
97
message
(s,sys);
98
}
else
{
99
for
(
const
QString& s : l)
100
message
(s+addtoend,sys);
101
}
102
}
103
104
//____________________________________________________________________
105
void
VP1Msg::messageDebug
(
const
QStringList& l,
const
QString& addtoend )
106
{
107
if
(!
debug
()){
108
return
;
109
}
110
if
(addtoend.isEmpty()) {
111
for
(
const
QString& s : l)
112
messageDebug
(s);
113
}
else
{
114
for
(
const
QString& s : l)
115
messageDebug
(s+addtoend);
116
}
117
}
118
119
//____________________________________________________________________
120
void
VP1Msg::messageVerbose
(
const
QStringList& l,
const
QString& addtoend )
121
{
122
if
(!
verbose
()){
123
return
;
124
}
125
if
(addtoend.isEmpty()) {
126
for
(
const
QString& s : l)
127
messageVerbose
(s);
128
}
else
{
129
for
(
const
QString& s : l)
130
messageVerbose
(s+addtoend);
131
}
132
}
133
134
//____________________________________________________________________
135
void
VP1Msg::message
(
const
QString& addtostart,
const
QStringList& l,
136
const
QString& addtoend,
IVP1System
*sys )
137
{
138
if
(addtostart.isEmpty()) {
139
message
(l,addtoend,sys);
140
return
;
141
}
142
if
(addtoend.isEmpty()) {
143
for
(
const
QString& s : l)
144
message
(addtostart+s,sys);
145
}
else
{
146
for
(
const
QString& s : l)
147
message
(addtostart+s+addtoend,sys);
148
}
149
}
150
151
//____________________________________________________________________
152
void
VP1Msg::messageDebug
(
const
QString& addtostart,
const
QStringList& l,
const
QString& addtoend )
153
{
154
if
(!
debug
()){
155
return
;
156
}
157
if
(addtostart.isEmpty()) {
158
messageDebug
(l,addtoend);
159
return
;
160
}
161
if
(addtoend.isEmpty()) {
162
for
(
const
QString& s : l)
163
messageDebug
(addtostart+s);
164
}
else
{
165
for
(
const
QString& s : l)
166
messageDebug
(addtostart+s+addtoend);
167
}
168
}
169
170
//____________________________________________________________________
171
void
VP1Msg::messageVerbose
(
const
QString& addtostart,
const
QStringList& l,
const
QString& addtoend )
172
{
173
if
(!
verbose
()){
174
return
;
175
}
176
if
(addtostart.isEmpty()) {
177
messageVerbose
(l,addtoend);
178
return
;
179
}
180
if
(addtoend.isEmpty()) {
181
for
(
const
QString& s : l)
182
messageVerbose
(addtostart+s);
183
}
else
{
184
for
(
const
QString& s : l)
185
messageVerbose
(addtostart+s+addtoend);
186
}
187
}
188
189
#if defined BUILDVP1LIGHT
190
void
VP1Msg::enableMsg
(
const
QString&
type
,
const
QString& name){
191
if
( name ==
"ExpertSettings/VP1_VERBOSE_OUTPUT"
){
192
VP1Msg::m_verbose
=
VP1QtUtils::expertSettingIsSet
(
type
, name);
193
}
else
{
194
VP1Msg::m_debug
=
VP1QtUtils::expertSettingIsSet
(type, name);
195
}
196
}
197
#else
198
void
VP1Msg::enableMsg
(
const
QString& name){
199
if
( name ==
"VP1_VERBOSE_OUTPUT"
){
200
VP1Msg::m_verbose
=
VP1QtUtils::environmentVariableIsSet
(name);
201
}
else
{
202
VP1Msg::m_debug
=
VP1QtUtils::environmentVariableIsSet
(name);
203
}
204
}
205
#endif
IVP1System.h
VP1Msg.h
VP1QtUtils.h
IVP1System
Definition
IVP1System.h:36
VP1Msg::debug
static bool debug()
Definition
VP1Msg.h:32
VP1Msg::prefix_warning
static const char * prefix_warning()
Definition
VP1Msg.h:58
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition
VP1Msg.cxx:84
VP1Msg::verbose
static bool verbose()
Definition
VP1Msg.h:31
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition
VP1Msg.cxx:39
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition
VP1Msg.cxx:30
VP1Msg::m_debug
static std::atomic< bool > m_debug
Definition
VP1Msg.h:65
VP1Msg::messageWarningRed
static void messageWarningRed(const QString &str, IVP1System *sys=0)
Definition
VP1Msg.cxx:57
VP1Msg::messageWarningAllRed
static void messageWarningAllRed(const QString &str, IVP1System *sys=0)
Definition
VP1Msg.cxx:70
VP1Msg::m_verbose
static std::atomic< bool > m_verbose
Definition
VP1Msg.h:64
VP1Msg::prefix_msg
static const char * prefix_msg()
Definition
VP1Msg.h:56
VP1Msg::messageWarning
static void messageWarning(const QString &, IVP1System *sys=0)
Definition
VP1Msg.cxx:48
VP1Msg::prefix_debug
static const char * prefix_debug()
Definition
VP1Msg.h:57
VP1Msg::prefix_verbose
static const char * prefix_verbose()
Definition
VP1Msg.h:59
VP1Msg::enableMsg
static void enableMsg(const QString &)
Definition
VP1Msg.cxx:198
VP1QtUtils::environmentVariableIsOn
static bool environmentVariableIsOn(const QString &name)
Definition
VP1QtUtils.cxx:127
VP1QtUtils::expertSettingIsSet
static bool expertSettingIsSet(const QString &type, const QString &name)
Definition
VP1QtUtils.cxx:27
VP1QtUtils::environmentVariableIsSet
static bool environmentVariableIsSet(const QString &name)
Definition
VP1QtUtils.cxx:108
str
Definition
BTagTrackIpAccessor.cxx:11
type
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0