4 #include "canvas_root_io/Streamers/BranchDescriptionStreamer.h" 5 #include "canvas_root_io/Streamers/CacheStreamers.h" 6 #include "canvas_root_io/Streamers/ProductIDStreamer.h" 7 #include "canvas_root_io/Streamers/RefCoreStreamer.h" 8 #include "canvas_root_io/Streamers/TransientStreamer.h" 9 #include "canvas_root_io/Streamers/setPtrVectorBaseStreamer.h" 23 enum class SeverityLevel { kInfo, kWarning, kError, kSysError, kFatal };
32 auto const npos = std::string::npos;
37 if (level >= kFatal) {
38 el_severity = SeverityLevel::kFatal;
39 }
else if (level >= kSysError) {
40 el_severity = SeverityLevel::kSysError;
41 }
else if (level >= kError) {
42 el_severity = SeverityLevel::kError;
43 }
else if (level >= kWarning) {
44 el_severity = SeverityLevel::kWarning;
50 std::string el_location{
"@SUB=?"};
51 if (location !=
nullptr) {
52 el_location =
"@SUB=" + std::string(location);
55 std::string el_message{
"?"};
56 if (message !=
nullptr) {
67 std::string el_identifier{
"ROOT"};
69 std::string
const precursor{
"class "};
70 size_t index1 = el_message.find(precursor);
72 size_t index2 = index1 + precursor.length();
73 size_t index3 = el_message.find_first_of(
" :", index2);
75 size_t substrlen = index3 - index2;
77 el_identifier += el_message.substr(index2, substrlen);
80 index1 = el_location.find(
"::");
83 el_identifier += el_location.substr(0, index1);
88 for (std::string
const&
s :
89 {
"art::Transient<art::ProductRegistry::Transients>",
90 "art::DoNotRecordParents"}) {
92 (std::string(
"no dictionary for class ") +
s +
" is available")) {
98 if ((el_location.find(
"TBranchElement::Fill") != npos) &&
99 (el_message.find(
"fill branch") != npos) &&
100 (el_message.find(
"address") != npos) &&
101 (el_message.find(
"not set") != npos)) {
102 el_severity = SeverityLevel::kFatal;
104 if ((el_message.find(
"Tree branches") != npos) &&
105 (el_message.find(
"different numbers of entries") != npos)) {
106 el_severity = SeverityLevel::kFatal;
110 if ((el_message.find(
"dictionary") != npos) ||
111 (el_message.find(
"already in TClassTable") != npos) ||
112 (el_message.find(
"matrix not positive definite") != npos) ||
113 (el_message.find(
"number of iterations was insufficient") != npos) ||
114 (el_message.find(
"bad integrand behavior") != npos) ||
115 (el_location.find(
"Fit") != npos) ||
116 (el_location.find(
"TDecompChol::Solve") != npos) ||
117 (el_location.find(
"THistPainter::PaintInit") != npos) ||
118 (el_location.find(
"TGClient::GetFontByName") != npos)) {
119 el_severity = SeverityLevel::kInfo;
122 if ((el_location.find(
"TUnixSystem::SetDisplay") != npos) &&
123 (el_message.find(
"DISPLAY not set") != npos)) {
124 el_severity = SeverityLevel::kInfo;
127 if ((el_location.find(
"TTree::ReadStream") != npos) &&
128 (el_message.find(
"Ignoring trailing") == 0)) {
129 el_severity = SeverityLevel::kInfo;
132 if (el_severity == SeverityLevel::kInfo) {
145 if (die && (location != std::string(
"TUnixSystem::DispatchSignals"))) {
146 std::ostringstream sstr;
147 sstr <<
"Fatal Root Error: " << el_location <<
"\n" << el_message <<
'\n';
154 if (el_severity == SeverityLevel::kFatal) {
155 mf::LogError(
"Root_Fatal") << el_location << el_message;
156 }
else if (el_severity == SeverityLevel::kSysError) {
157 mf::LogError(
"Root_Severe") << el_location << el_message;
158 }
else if (el_severity == SeverityLevel::kError) {
159 mf::LogError(
"Root_Error") << el_location << el_message;
160 }
else if (el_severity == SeverityLevel::kWarning) {
162 }
else if (el_severity == SeverityLevel::kInfo) {
163 mf::LogInfo(
"Root_Information") << el_location << el_message;
174 gSystem->ResetSignal(kSigChild);
175 gSystem->ResetSignal(kSigBus);
176 gSystem->ResetSignal(kSigSegmentationViolation);
177 gSystem->ResetSignal(kSigIllegalInstruction);
178 gSystem->ResetSignal(kSigSystem);
179 gSystem->ResetSignal(kSigPipe);
180 gSystem->ResetSignal(kSigAlarm);
181 gSystem->ResetSignal(kSigUrgent);
182 gSystem->ResetSignal(kSigFloatingException);
183 gSystem->ResetSignal(kSigWindowChanged);
192 SetErrorHandler(DefaultErrorHandler);
200 ROOT::EnableThreadSafety();
201 TTree::SetMaxTreeSize(kMaxLong64);
202 TH1::AddDirectory(kFALSE);
209 setProvenanceTransientStreamers();
210 detail::setBranchDescriptionStreamer();
211 detail::setPtrVectorBaseStreamer();
212 configureProductIDStreamer();
213 configureRefCoreStreamer();
void unloadRootSigHandler()
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void setRootErrorHandler(bool const want_custom)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void completeRootHandlers()
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning