Project
Loading...
Searching...
No Matches
LogParsingHelpers.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
12#include <regex>
13
14namespace o2::framework
15{
16
17char const* const LogParsingHelpers::LOG_LEVELS[(int)LogParsingHelpers::LogLevel::Size] = {
18 "DEBUG",
19 "INFO",
20 "IMPORTANT",
21 "WARNING",
22 "ALARM",
23 "ERROR",
24 "CRITICAL",
25 "FATAL",
26 "UNKNOWN"};
28
30{
31
32 // Example format: [99:99:99][ERROR] (string begins with that, longest is 17 chars)
33 constexpr size_t MAXPREFLEN = 17;
34 constexpr size_t LABELPOS = 10;
35 if (s.size() < MAXPREFLEN && s.find("*** Break ***") == std::string::npos && !s.starts_with("[INFO]")) {
36 return LogLevel::Unknown;
37 }
38
39 // Check if first chars match [NN:NN:NN]
40 // 0123456789
41 if ((unsigned char)s[0] != '[' || (unsigned char)s[9] != ']' ||
42 (unsigned char)s[3] != ':' || (unsigned char)s[6] != ':' ||
43 (unsigned char)s[1] - '0' > 9 || (unsigned char)s[2] - '0' > 9 ||
44 (unsigned char)s[4] - '0' > 9 || (unsigned char)s[5] - '0' > 9 ||
45 (unsigned char)s[7] - '0' > 9 || (unsigned char)s[8] - '0' > 9) {
46 if (s.starts_with("Info in <") || s.starts_with("Print in <") || s.starts_with("[INFO]")) {
47 return LogLevel::Info;
48 } else if (s.starts_with("Warning in <")) {
49 return LogLevel::Warning;
50 } else if (s.find("Error in <") != std::string::npos) {
51 return LogLevel::Error;
52 } else if (s.starts_with("Fatal in <") || s.find("*** Break ***") != std::string::npos) {
53 return LogLevel::Fatal;
54 } else {
55 return LogLevel::Unknown;
56 }
57 }
58
59 if (s.compare(LABELPOS, 8, "[DEBUG] ") == 0) {
60 return LogLevel::Debug;
61 } else if (s.compare(LABELPOS, 7, "[INFO] ") == 0 ||
62 s.compare(LABELPOS, 8, "[STATE] ") == 0) {
63 return LogLevel::Info;
64 } else if (s.compare(LABELPOS, 12, "[IMPORTANT] ") == 0) {
65 return LogLevel::Important;
66 } else if (s.compare(LABELPOS, 7, "[WARN] ") == 0) {
67 return LogLevel::Warning;
68 } else if (s.compare(LABELPOS, 8, "[ALARM] ") == 0) {
69 return LogLevel::Alarm;
70 } else if (s.compare(LABELPOS, 8, "[ERROR] ") == 0) {
71 return LogLevel::Error;
72 } else if (s.compare(LABELPOS, 11, "[CRITICAL] ") == 0) {
73 return LogLevel::Critical;
74 } else if (s.compare(LABELPOS, 8, "[FATAL] ") == 0) {
75 return LogLevel::Fatal;
76 }
77 return LogLevel::Unknown;
78}
79} // namespace o2
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
uint8_t int statusCode int
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
LogLevel
Possible log levels for device log entries.
static LogLevel parseTokenLevel(std::string_view const s)
static char const *const LOG_LEVELS[(int) LogLevel::Size]
Available log levels.