libdebian-installer
Di_log

Macros

#define di_error(format...)
#define di_warning(format...)
#define di_info(format...)
#define di_debug(format...)

Typedefs

typedef void di_log_handler(di_log_level_flags log_level, const char *message, void *user_data)

Enumerations

enum  di_log_level_flags {
  DI_LOG_FLAG_FATAL = 1 << 1 , DI_LOG_LEVEL_ERROR = 1 << 2 , DI_LOG_LEVEL_CRITICAL = 1 << 3 , DI_LOG_LEVEL_WARNING = 1 << 4 ,
  DI_LOG_LEVEL_MESSAGE = 1 << 5 , DI_LOG_LEVEL_INFO = 1 << 6 , DI_LOG_LEVEL_DEBUG = 1 << 7 , DI_LOG_LEVEL_OUTPUT = 1 << 8 ,
  DI_LOG_LEVEL_MASK = ~DI_LOG_FLAG_FATAL , DI_LOG_FATAL_MASK = DI_LOG_LEVEL_ERROR
}
 Log levels and other flags. More...

Functions

void di_log (di_log_level_flags log_level, const char *format,...) __attribute__((format(printf
void void di_vlog (di_log_level_flags log_level, const char *format, va_list args)
unsigned int di_log_set_handler (di_log_level_flags log_levels, di_log_handler *log_func, void *user_data)

Variables

di_log_handler di_log_handler_default
di_log_handler di_log_handler_syslog

Detailed Description

Macro Definition Documentation

◆ di_debug

#define di_debug ( format...)
Value:
void di_log(di_log_level_flags log_level, const char *format,...) __attribute__((format(printf
@ DI_LOG_LEVEL_DEBUG
Definition log.h:42

logs debug info

◆ di_error

#define di_error ( format...)
Value:
@ DI_LOG_LEVEL_ERROR
Definition log.h:37

logs an error

Referenced by di_malloc(), di_malloc0(), and di_realloc().

◆ di_info

#define di_info ( format...)
Value:
@ DI_LOG_LEVEL_INFO
Definition log.h:41

logs information

◆ di_warning

#define di_warning ( format...)
Value:
@ DI_LOG_LEVEL_WARNING
Definition log.h:39

logs a warning

Referenced by di_parser_rfc822_read().

Enumeration Type Documentation

◆ di_log_level_flags

Log levels and other flags.

Enumerator
DI_LOG_FLAG_FATAL 

flag as fatal

DI_LOG_LEVEL_ERROR 

error level, always fatal

DI_LOG_LEVEL_CRITICAL 

critical level

DI_LOG_LEVEL_WARNING 

warning level

DI_LOG_LEVEL_MESSAGE 

message level

DI_LOG_LEVEL_INFO 

information level

DI_LOG_LEVEL_DEBUG 

debug level

DI_LOG_LEVEL_OUTPUT 

command output

DI_LOG_LEVEL_MASK 

defines mask for levels

DI_LOG_FATAL_MASK 

defines always fatal levels

34{
35 DI_LOG_FLAG_FATAL = 1 << 1,
36
37 DI_LOG_LEVEL_ERROR = 1 << 2,
38 DI_LOG_LEVEL_CRITICAL = 1 << 3,
39 DI_LOG_LEVEL_WARNING = 1 << 4,
40 DI_LOG_LEVEL_MESSAGE = 1 << 5,
41 DI_LOG_LEVEL_INFO = 1 << 6,
42 DI_LOG_LEVEL_DEBUG = 1 << 7,
43 DI_LOG_LEVEL_OUTPUT = 1 << 8,
44
47}
@ DI_LOG_LEVEL_MASK
Definition log.h:45
@ DI_LOG_LEVEL_MESSAGE
Definition log.h:40
@ DI_LOG_FLAG_FATAL
Definition log.h:35
@ DI_LOG_LEVEL_CRITICAL
Definition log.h:38
@ DI_LOG_FATAL_MASK
Definition log.h:46
@ DI_LOG_LEVEL_OUTPUT
Definition log.h:43

Function Documentation

◆ di_log()

void di_log ( di_log_level_flags log_level,
const char * format,
... )

Logs the resolved formatstring with log_level

Parameters
log_levelthe level of the message
formatprintf compatible format

References di_log_set_handler(), and di_vlog().

◆ di_log_set_handler()

unsigned int di_log_set_handler ( di_log_level_flags log_levels,
di_log_handler * log_func,
void * user_data )

Sets a log handler

Parameters
log_levelslevels
log_functhe log handler
user_datadata for log_func
190{
191 static unsigned int handler_id = 0;
192 di_log_handler_struct *handler;
193
194 handler = di_new (di_log_handler_struct, 1);
195
196 handler->id = ++handler_id;
197 handler->log_level = log_levels;
198 handler->log_func = log_func;
199 handler->user_data = user_data;
200
201 di_slist_append (&handlers, handler);
202
203 return handler_id;
204}
#define di_new(struct_type, n_structs)
Definition mem.h:73
void di_slist_append(di_slist *slist, void *data) __attribute__((nonnull(1)))
Definition slist.c:68
Log handler info.
Definition log.c:47
void * user_data
Definition log.c:51
di_log_handler * log_func
Definition log.c:50
di_log_level_flags log_level
Definition log.c:49
unsigned int id
Definition log.c:48

References di_new, di_slist_append(), di_log_handler_struct::id, di_log_handler_struct::log_func, di_log_handler_struct::log_level, and di_log_handler_struct::user_data.

Referenced by di_log(), and di_system_init().

◆ di_vlog()

void void di_vlog ( di_log_level_flags log_level,
const char * format,
va_list args )

Logs the resolved formatstring with log_level

Parameters
log_levelthe level of the message
formatprintf compatible format
argsvariable arguments list
218{
219 char buf[1024];
220 int fatal = log_level & DI_LOG_FATAL_MASK;
221 di_log_handler *log_func;
222 void *user_data=0;
223
224 vsnprintf (buf, sizeof (buf), format, args);
225
226 log_func = internal_di_log_get_handler (log_level, &user_data);
227
228 log_func (log_level, buf, user_data);
229
230 if (fatal)
231 exit (1);
232}

References DI_LOG_FATAL_MASK.

Referenced by di_log().

Variable Documentation

◆ di_log_handler_default

di_log_handler di_log_handler_default

Default log handler. Logs to STDOUT and STDERR.

◆ di_log_handler_syslog

di_log_handler di_log_handler_syslog

SYSLOG log handler. Logs to SYSLOG.

Referenced by di_system_init().