libdebian-installer
log.h
1 /*
2  * log.h
3  *
4  * Copyright (C) 2003 Bastian Blank <waldi@debian.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef DEBIAN_INSTALLER__LOG_H
21 #define DEBIAN_INSTALLER__LOG_H
22 
23 #include <stdarg.h>
24 
33 typedef enum
34 {
35  DI_LOG_FLAG_FATAL = 1 << 1,
37  DI_LOG_LEVEL_ERROR = 1 << 2,
41  DI_LOG_LEVEL_INFO = 1 << 6,
42  DI_LOG_LEVEL_DEBUG = 1 << 7,
47 }
49 
50 typedef void di_log_handler (di_log_level_flags log_level, const char *message, void *user_data);
51 
55 #define di_error(format...) di_log (DI_LOG_LEVEL_ERROR, format)
56 
59 #define di_warning(format...) di_log (DI_LOG_LEVEL_WARNING, format)
60 
63 #define di_info(format...) di_log (DI_LOG_LEVEL_INFO, format)
64 
67 #define di_debug(format...) di_log (DI_LOG_LEVEL_DEBUG, format)
68 
75 void di_log (di_log_level_flags log_level, const char *format, ...) __attribute__ ((format(printf,2,3)));
83 void di_vlog (di_log_level_flags log_level, const char *format, va_list args);
84 
92 unsigned int di_log_set_handler (di_log_level_flags log_levels, di_log_handler *log_func, void *user_data);
93 
94 di_log_handler
105 
107 #endif