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
DI_LOG_LEVEL_CRITICAL
@ DI_LOG_LEVEL_CRITICAL
Definition: log.h:38
di_log_handler_struct::user_data
void * user_data
Definition: log.c:51
di_log_handler_syslog
di_log_handler di_log_handler_syslog
Definition: log.h:104
di_slist_node::next
di_slist_node * next
Definition: slist.h:47
di_slist
Single-linked list.
Definition: slist.h:36
di_log_handler_struct::log_level
di_log_level_flags log_level
Definition: log.c:49
di_log_level_flags
di_log_level_flags
Log levels and other flags.
Definition: log.h:33
di_log_handler_struct::log_func
di_log_handler * log_func
Definition: log.c:50
di_new
#define di_new(struct_type, n_structs)
Definition: mem.h:73
DI_LOG_LEVEL_MASK
@ DI_LOG_LEVEL_MASK
Definition: log.h:45
di_slist_append
void di_slist_append(di_slist *slist, void *data) __attribute__((nonnull(1)))
Definition: slist.c:68
di_log_handler_struct
Log handler info.
Definition: log.c:46
di_log_set_handler
unsigned int di_log_set_handler(di_log_level_flags log_levels, di_log_handler *log_func, void *user_data)
Definition: log.c:189
DI_LOG_LEVEL_MESSAGE
@ DI_LOG_LEVEL_MESSAGE
Definition: log.h:40
di_log
void di_log(di_log_level_flags log_level, const char *format,...) __attribute__((format(printf
DI_LOG_LEVEL_OUTPUT
@ DI_LOG_LEVEL_OUTPUT
Definition: log.h:43
di_slist_node
Node of a single-linked list.
Definition: slist.h:45
di_slist::head
di_slist_node * head
Definition: slist.h:38
DI_LOG_FLAG_FATAL
@ DI_LOG_FLAG_FATAL
Definition: log.h:35
DI_LOG_LEVEL_INFO
@ DI_LOG_LEVEL_INFO
Definition: log.h:41
di_slist_node::data
void * data
Definition: slist.h:48
di_progname_get
const char * di_progname_get(void)
Definition: utils.c:33
di_log_handler_default
di_log_handler di_log_handler_default
Definition: log.h:99
di_vlog
void di_vlog(di_log_level_flags log_level, const char *format, va_list args)
Definition: log.c:217
di_log_handler_struct::id
unsigned int id
Definition: log.c:48
DI_LOG_FATAL_MASK
@ DI_LOG_FATAL_MASK
Definition: log.h:46
DI_LOG_LEVEL_ERROR
@ DI_LOG_LEVEL_ERROR
Definition: log.h:37
DI_LOG_LEVEL_DEBUG
@ DI_LOG_LEVEL_DEBUG
Definition: log.h:42
DI_LOG_LEVEL_WARNING
@ DI_LOG_LEVEL_WARNING
Definition: log.h:39