| 1 | /* |
| 2 | * AIDE (Advanced Intrusion Detection Environment) |
| 3 | * |
| 4 | * Copyright (C) 2020, 2022, 2023, 2025 Hannes von Haugwitz |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of the |
| 9 | * License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _LOG_H_INCLUDED |
| 22 | #define _LOG_H_INCLUDEDcxx . . $ `include/log.h:22:10`! |
| 23 | |
| 24 | #include <stdbool.h> |
| 25 | |
| 26 | /* log levels */ |
| 27 | typedef enumcxx . . $ $anonymous_type_af5a4ae024e29415_0# { /* preserve order */ |
| 28 | LOG_LEVEL_UNSETcxx . . $ LOG_LEVEL_UNSET. = 0, |
| 29 | LOG_LEVEL_ERRORcxx . . $ LOG_LEVEL_ERROR. = 1, |
| 30 | LOG_LEVEL_WARNINGcxx . . $ LOG_LEVEL_WARNING. = 2, |
| 31 | LOG_LEVEL_NOTICEcxx . . $ LOG_LEVEL_NOTICE. = 3, |
| 32 | LOG_LEVEL_INFOcxx . . $ LOG_LEVEL_INFO. = 4, |
| 33 | LOG_LEVEL_COMPAREcxx . . $ LOG_LEVEL_COMPARE. = 5, |
| 34 | LOG_LEVEL_RULEcxx . . $ LOG_LEVEL_RULE. = 6, |
| 35 | LOG_LEVEL_CONFIGcxx . . $ LOG_LEVEL_CONFIG. = 7, |
| 36 | LOG_LEVEL_DEBUGcxx . . $ LOG_LEVEL_DEBUG. = 8, |
| 37 | LOG_LEVEL_LIMITcxx . . $ LOG_LEVEL_LIMIT. = 9, |
| 38 | LOG_LEVEL_THREADcxx . . $ LOG_LEVEL_THREAD. = 10, |
| 39 | LOG_LEVEL_TRACEcxx . . $ LOG_LEVEL_TRACE. = 11, |
| 40 | } LOG_LEVELcxx . . $ LOG_LEVEL#; |
| 41 | |
| 42 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! is_log_level_unsetcxx . . $ is_log_level_unset(c9857a73d68e59ba).(void); |
| 43 | |
| 44 | void set_log_levelcxx . . $ set_log_level(acc15b7e06406d4e).(LOG_LEVELcxx . . $ LOG_LEVEL#); |
| 45 | void set_colored_logcxx . . $ set_colored_log(b45ddcbc8423892c).(boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`!); |
| 46 | |
| 47 | const char * get_log_level_namecxx . . $ get_log_level_name(3ac032694a5a1d08).(LOG_LEVELcxx . . $ LOG_LEVEL#); |
| 48 | |
| 49 | LOG_LEVELcxx . . $ LOG_LEVEL# get_log_level_from_stringcxx . . $ get_log_level_from_string(1c46f449ef604568).(char*); |
| 50 | |
| 51 | LOG_LEVELcxx . . $ LOG_LEVEL# toogle_log_levelcxx . . $ toogle_log_level(e02209862df775c8).(LOG_LEVELcxx . . $ LOG_LEVEL#); |
| 52 | |
| 53 | void log_msgcxx . . $ log_msg(e585f2b5603b5bf9).(LOG_LEVELcxx . . $ LOG_LEVEL#, const char* ,...) |
| 54 | #ifdef __GNUC__cxx . . $ `<built-in>:8:9`! |
| 55 | __attribute__ ((format (printf, 2, 3))) |
| 56 | #endif |
| 57 | ; |
| 58 | |
| 59 | #define LOG_CONFIG_FORMAT_LINEcxx . . $ `include/log.h:59:9`!(log_level, format, ...) \ |
| 60 | if (linebuf) { \ |
| 61 | log_msg(log_level,"%s:%d: " format " (line: '%s')", filename, linenumber, __VA_ARGS__, linebuf); \ |
| 62 | } else { \ |
| 63 | log_msg(log_level,"%s: " format, filename, __VA_ARGS__); \ |
| 64 | } |
| 65 | |
| 66 | #define LOG_CONFIG_FORMAT_LINE_PREFIXcxx . . $ `include/log.h:66:9`!(log_level, format, ...) \ |
| 67 | if (rule_prefix) { \ |
| 68 | log_msg(log_level,"%s:%d: " format " (line: '%s', prefix: '%s')", filename, linenumber, __VA_ARGS__, linebuf, rule_prefix); \ |
| 69 | } else { \ |
| 70 | log_msg(log_level,"%s:%d: " format " (line: '%s')", filename, linenumber, __VA_ARGS__, linebuf); \ |
| 71 | } |
| 72 | |
| 73 | #define LOG_WHOAMIcxx . . $ `include/log.h:73:9`!(log_level, format, ...) log_msg(log_level, "%*s%s" format, whoami?10:0, whoami?whoami:"", whoami?": ":"", __VA_ARGS__); |
| 74 | |
| 75 | #endif |