ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
RootCoreUtils
Root
Message.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
11
#include <
RootCoreUtils/Message.h
>
12
13
#include <cstdlib>
14
#include <cstring>
15
#include <iostream>
16
#include <sstream>
17
#include <stdexcept>
18
#include <
RootCoreUtils/Assert.h
>
19
#include <
RootCoreUtils/MessageCheck.h
>
20
21
//
22
// method implementations
23
//
24
25
namespace
RCU
26
{
27
Message ::
28
Message ()
29
:
file
(nullptr),
line
(0),
type
(
MESSAGE_UNSPECIFIED
),
30
message
(nullptr)
31
{
32
}
33
34
35
36
void
Message ::
37
send ()
const
38
{
39
using namespace
msgRootCoreUtils;
40
41
MessageType
mytype =
type
;
42
if
(mytype < 0 || mytype >
MESSAGE_UNSPECIFIED
)
43
mytype =
MESSAGE_UNSPECIFIED
;
44
45
std::ostringstream
str
;
46
47
if
(
file
!=
nullptr
)
48
{
49
if
(strncmp (
file
,
"../"
, 3) == 0)
50
str
<< (
file
+3) <<
":"
;
51
else
52
str
<<
file
<<
":"
;
53
}
54
if
(
line
!= 0)
55
str
<<
line
<<
":"
;
56
57
if
(mytype !=
MESSAGE_UNSPECIFIED
)
58
{
59
static
const
char
*
const
type_names[
MESSAGE_UNSPECIFIED
] =
60
{
"message"
,
"warning"
,
"error"
,
"exception"
,
"abort"
};
61
str
<< type_names[mytype] <<
":"
;
62
}
63
64
if
(!
str
.str().empty())
65
str
<<
" "
;
66
if
(
message
!=
nullptr
)
67
str
<<
message
;
68
else
69
str
<<
"(null)"
;
70
71
const
char
*envname =
nullptr
;
72
if
(mytype ==
MESSAGE_ABORT
)
73
envname =
"ROOTCOREUTILS_ABORT"
;
74
else
if
(mytype ==
MESSAGE_EXCEPTION
)
75
envname =
"ROOTCOREUTILS_EXCEPTION"
;
76
if
(envname)
77
{
78
const
char
*abort_type = getenv (envname);
79
const
MessageType
def_type =
MESSAGE_EXCEPTION
;
80
81
if
(abort_type ==
nullptr
)
82
{
83
mytype = def_type;
84
}
else
if
(strcmp (abort_type,
"abort"
) == 0)
85
{
86
mytype =
MESSAGE_ABORT
;
87
}
else
if
(strcmp (abort_type,
"exception"
) == 0)
88
{
89
mytype =
MESSAGE_EXCEPTION
;
90
}
else
91
{
92
mytype = def_type;
93
94
ANA_MSG_WARNING
(std::string (
"unknown value for "
) << envname <<
" "
<< abort_type);
95
}
96
}
97
98
std::cout <<
str
.str() << std::endl;
99
if
(mytype ==
MESSAGE_EXCEPTION
)
100
throw
std::runtime_error (
str
.str());
101
if
(mytype ==
MESSAGE_ABORT
)
102
std::abort ();
103
}
104
}
Assert.h
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg,...)
Macro printing warning messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:293
MessageCheck.h
Message.h
RCU
This module defines a variety of assert style macros.
Definition
Assert.cxx:23
RCU::MessageType
MessageType
Definition
MessageType.h:17
RCU::MESSAGE_ABORT
@ MESSAGE_ABORT
description: print and abort
Definition
MessageType.h:31
RCU::MESSAGE_UNSPECIFIED
@ MESSAGE_UNSPECIFIED
description: unspecified message type
Definition
MessageType.h:34
RCU::MESSAGE_EXCEPTION
@ MESSAGE_EXCEPTION
description: send out an exception
Definition
MessageType.h:28
str
Definition
BTagTrackIpAccessor.cxx:11
RCU::Message::file
const char * file
description: the location where the message was send
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:22
RCU::Message::type
MessageType type
description: the type of this message
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:28
RCU::Message::line
unsigned line
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:24
RCU::Message::message
const char * message
description: the actual message we are sending or 0 if there isn't one
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:33
Generated on
for ATLAS Offline Software by
1.17.0