libdebian-installer
|
00001 /* 00002 * log.h 00003 * 00004 * Copyright (C) 2003 Bastian Blank <waldi@debian.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef DEBIAN_INSTALLER__LOG_H 00021 #define DEBIAN_INSTALLER__LOG_H 00022 00023 #include <stdarg.h> 00024 00033 typedef enum 00034 { 00035 DI_LOG_FLAG_FATAL = 1 << 1, 00037 DI_LOG_LEVEL_ERROR = 1 << 2, 00038 DI_LOG_LEVEL_CRITICAL = 1 << 3, 00039 DI_LOG_LEVEL_WARNING = 1 << 4, 00040 DI_LOG_LEVEL_MESSAGE = 1 << 5, 00041 DI_LOG_LEVEL_INFO = 1 << 6, 00042 DI_LOG_LEVEL_DEBUG = 1 << 7, 00043 DI_LOG_LEVEL_OUTPUT = 1 << 8, 00045 DI_LOG_LEVEL_MASK = ~DI_LOG_FLAG_FATAL, 00046 DI_LOG_FATAL_MASK = DI_LOG_LEVEL_ERROR, 00047 } 00048 di_log_level_flags; 00049 00050 typedef void di_log_handler (di_log_level_flags log_level, const char *message, void *user_data); 00051 00055 #define di_error(format...) di_log (DI_LOG_LEVEL_ERROR, format) 00056 00059 #define di_warning(format...) di_log (DI_LOG_LEVEL_WARNING, format) 00060 00063 #define di_info(format...) di_log (DI_LOG_LEVEL_INFO, format) 00064 00067 #define di_debug(format...) di_log (DI_LOG_LEVEL_DEBUG, format) 00068 00075 void di_log (di_log_level_flags log_level, const char *format, ...) __attribute__ ((format(printf,2,3))); 00083 void di_vlog (di_log_level_flags log_level, const char *format, va_list args); 00084 00092 unsigned int di_log_set_handler (di_log_level_flags log_levels, di_log_handler *log_func, void *user_data); 00093 00094 di_log_handler 00099 di_log_handler_default, 00104 di_log_handler_syslog; 00105 00107 #endif