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 <
RootCoreUtils/Assert.h
>
18
#include <
RootCoreUtils/ExceptionMsg.h
>
19
#include <
RootCoreUtils/PrintMsg.h
>
20
21
//
22
// method implementations
23
//
24
25
namespace
RCU
26
{
27
Message ::
28
Message ()
29
:
package
(0),
file
(0),
line
(0),
type
(
MESSAGE_UNSPECIFIED
),
30
message
(0)
31
{
32
}
33
34
35
36
void
Message ::
37
send ()
const
38
{
39
MessageType
mytype =
type
;
40
if
(mytype < 0 || mytype >
MESSAGE_UNSPECIFIED
)
41
mytype =
MESSAGE_UNSPECIFIED
;
42
43
std::ostringstream
str
;
44
45
if
(
package
!= 0)
46
{
47
str
<<
package
<< ":";
48
}
49
if
(
file
!= 0)
50
{
51
if
(strncmp (
file
,
"../"
, 3) == 0)
52
str
<< (
file
+3) <<
":"
;
53
else
54
str
<<
file
<<
":"
;
55
}
56
if
(
line
!= 0)
57
str
<<
line
<<
":"
;
58
59
if
(mytype !=
MESSAGE_UNSPECIFIED
)
60
{
61
static
const
char
*
const
type_names[
MESSAGE_UNSPECIFIED
] =
62
{
"message"
,
"warning"
,
"error"
,
"exception"
,
"abort"
};
63
str
<< type_names[mytype] <<
":"
;
64
}
65
66
if
(!
str
.str().empty())
67
str
<<
" "
;
68
if
(
message
!= 0)
69
str
<<
message
;
70
else
71
str
<<
"(null)"
;
72
73
const
char
*envname = 0;
74
if
(mytype ==
MESSAGE_ABORT
)
75
envname =
"ROOTCOREUTILS_ABORT"
;
76
else
if
(mytype ==
MESSAGE_EXCEPTION
)
77
envname =
"ROOTCOREUTILS_EXCEPTION"
;
78
if
(envname)
79
{
80
const
char
*abort_type = getenv (envname);
81
const
MessageType
def_type =
MESSAGE_EXCEPTION
;
82
83
if
(abort_type == 0)
84
{
85
mytype = def_type;
86
}
else
if
(strcmp (abort_type,
"abort"
) == 0)
87
{
88
mytype =
MESSAGE_ABORT
;
89
}
else
if
(strcmp (abort_type,
"exception"
) == 0)
90
{
91
mytype =
MESSAGE_EXCEPTION
;
92
}
else
93
{
94
mytype = def_type;
95
96
RCU_WARN_MSG
(std::string (
"unknown value for ROOTCOREUTILS_ABORT "
) + abort_type);
97
}
98
}
99
100
std::cout <<
str
.str() << std::endl;
101
if
(mytype ==
MESSAGE_EXCEPTION
)
102
throw
ExceptionMsg
(
file
,
line
,
str
.str());
103
if
(mytype ==
MESSAGE_ABORT
)
104
std::abort ();
105
}
106
}
Assert.h
ExceptionMsg.h
Message.h
PrintMsg.h
RCU_WARN_MSG
#define RCU_WARN_MSG(message)
Definition
PrintMsg.h:47
RCU::ExceptionMsg
Definition
ExceptionMsg.h:24
RCU
This module defines a variety of assert style macros.
Definition
Assert.cxx:23
RCU::MessageType
MessageType
Definition
MessageType.h:19
RCU::MESSAGE_ABORT
@ MESSAGE_ABORT
description: print and abort
Definition
MessageType.h:33
RCU::MESSAGE_UNSPECIFIED
@ MESSAGE_UNSPECIFIED
description: unspecified message type
Definition
MessageType.h:36
RCU::MESSAGE_EXCEPTION
@ MESSAGE_EXCEPTION
description: send out an exception
Definition
MessageType.h:30
str
Definition
BTagTrackIpAccessor.cxx:11
RCU::Message::file
const char * file
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:26
RCU::Message::package
const char * package
description: the location where the message was send
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:24
RCU::Message::type
MessageType type
description: the type of this message
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:32
RCU::Message::line
unsigned line
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:28
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:37
Generated on
for ATLAS Offline Software by
1.17.0