ATLAS Offline Software
error.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 #ifdef __GXX_ABI_VERSION
15 # include <cstdlib>
16 # include <cxxabi.h>
17 #endif
18 #include <iomanip>
19 #include <iostream>
20 #include <sstream>
21 
22 
23 #ifdef XAOD_STANDALONE
24 
25 
26 namespace AthContainers_detail {
27 
28 
30 void reportMessageStandalone (const std::string& context,
31  const std::string& severity,
32  const std::string& file, int line,
33  const std::string& msg) {
34 
35  // Make sure that the message's source/location is not longer than a
36  // pre-set maximum value.
37  std::string source (context);
38  static constexpr std::size_t CONTEXT_WIDTH = 18;
39  if (source.size() > CONTEXT_WIDTH) {
40  source = source.substr(0, CONTEXT_WIDTH - 3);
41  source += "...";
42  }
43 
44  // Print the message to stdout/std::cout.
45  std::ostringstream output;
46  output << std::setiosflags(std::ios::left)
47  << std::setw(CONTEXT_WIDTH) << source << " " << severity << " "
48  << file << ":" << line << ": "
49  << msg;
50  std::cout << output.str() << std::endl;
51  return;
52 }
53 
54 
64 std::string typeinfoName (const std::type_info& ti)
65 {
66  // In case the "translation" is not successful, the fallback is to
67  // keep the original, mangled name:
68  std::string result = ti.name();
69 
70 #ifdef __GXX_ABI_VERSION
71  // Try to demangle the name:
72  int status;
73  char* typeName = abi::__cxa_demangle( ti.name(), 0, 0, &status );
74  if (status == 0) {
75  // Take the demangled name, and free up the memory allocated in
76  // the process:
77  result = typeName;
78  ::free( typeName );
79  }
80 #endif
81 
82  return result;
83 }
84 
85 
86 } // namespace AthContainers_detail
87 
88 
89 #endif // XAOD_STANDALONE
checkFileSG.line
line
Definition: checkFileSG.py:75
get_generator_info.result
result
Definition: get_generator_info.py:21
AthContainers_detail
Definition: concurrent_vector.h:54
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
file
TFile * file
Definition: tile_monitor.h:29
error.h
Helper for emitting error messages.
merge.output
output
Definition: merge.py:17
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
copySelective.source
string source
Definition: copySelective.py:32
merge.status
status
Definition: merge.py:17
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7