1 /*************************************************************************
3 * Copyright 2020 highstreet technologies GmbH and others
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
21 #include "utils/log_utils.h"
22 #include "utils/rand_utils.h"
23 #include "utils/sys_utils.h"
28 static fault_counters_t fault_counters;
30 fault_counters_t faults_counters_get(void) {
31 return fault_counters;
34 void faults_counters_clear(void) {
35 fault_counters.normal = 0;
36 fault_counters.warning = 0;
37 fault_counters.minor = 0;
38 fault_counters.major = 0;
39 fault_counters.critical = 0;
42 int faults_counters_increase(const char *severity) {
46 if(strcmp(severity, "NORMAL") == 0) {
47 fault_counters.normal++;
49 else if(strcmp(severity, "WARNING") == 0) {
50 fault_counters.warning++;
52 else if(strcmp(severity, "MINOR") == 0) {
53 fault_counters.minor++;
55 else if(strcmp(severity, "MAJOR") == 0) {
56 fault_counters.major++;
58 else if(strcmp(severity, "CRITICAL") == 0) {
59 fault_counters.critical++;
62 log_error("severity not found: %s\n", severity);