1 /* 2 * AIDE (Advanced Intrusion Detection Environment) 3 * 4 * Copyright (C) 2020 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_INCLUDED 23 24 #include <stdarg.h> 25 #include <stdbool.h> 26 27 /* log levels */ 28 typedef enum { /* preserve order */ 29 LOG_LEVEL_UNSET = 0, 30 LOG_LEVEL_ERROR = 1, 31 LOG_LEVEL_WARNING = 2, 32 LOG_LEVEL_NOTICE = 3, 33 LOG_LEVEL_INFO = 4, 34 LOG_LEVEL_RULE = 5, 35 LOG_LEVEL_CONFIG = 6, 36 LOG_LEVEL_DEBUG = 7, 37 LOG_LEVEL_TRACE = 8, 38 } LOG_LEVEL; 39 40 bool is_log_level_unset(); 41 42 void set_log_level(LOG_LEVEL); 43 44 const char * get_log_level_name(LOG_LEVEL); 45 46 LOG_LEVEL get_log_level_from_string(char*); 47 48 LOG_LEVEL toogle_log_level(LOG_LEVEL); 49 50 void log_msg(LOG_LEVEL, const char* ,...); 51 52 #define LOG_CONFIG_FORMAT_LINE(log_level, format, ...) \ 53 if (linebuf) { \ 54 log_msg(log_level,"%s:%d: " #format " (line: '%s')", filename, linenumber, __VA_ARGS__, linebuf); \ 55 } else { \ 56 log_msg(log_level,"%s: " #format, filename, __VA_ARGS__); \ 57 } 58 59 #endif 60