4
* Copyright (C) 2003 Bastian Blank <waldi@debian.org>
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.
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.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* $Id: log.h 11699 2004-03-22 09:35:42Z waldi $
23
#ifndef DEBIAN_INSTALLER__LOG_H
24
#define DEBIAN_INSTALLER__LOG_H
34
* @brief Log levels and other flags
38
DI_LOG_FLAG_FATAL = 1 << 1, /**< flag as fatal */
40
DI_LOG_LEVEL_ERROR = 1 << 2, /**< error level, always fatal */
41
DI_LOG_LEVEL_CRITICAL = 1 << 3, /**< critical level */
42
DI_LOG_LEVEL_WARNING = 1 << 4, /**< warning level */
43
DI_LOG_LEVEL_MESSAGE = 1 << 5, /**< message level */
44
DI_LOG_LEVEL_INFO = 1 << 6, /**< information level */
45
DI_LOG_LEVEL_DEBUG = 1 << 7, /**< debug level */
46
DI_LOG_LEVEL_OUTPUT = 1 << 8, /**< command output */
48
DI_LOG_LEVEL_MASK = ~DI_LOG_FLAG_FATAL, /**< defines mask for levels */
49
DI_LOG_FATAL_MASK = DI_LOG_LEVEL_ERROR, /**< defines always fatal levels */
53
typedef void di_log_handler (di_log_level_flags log_level, const char *message, void *user_data);
58
#define di_error(format...) di_log (DI_LOG_LEVEL_ERROR, format)
62
#define di_warning(format...) di_log (DI_LOG_LEVEL_WARNING, format)
66
#define di_info(format...) di_log (DI_LOG_LEVEL_INFO, format)
70
#define di_debug(format...) di_log (DI_LOG_LEVEL_DEBUG, format)
73
* Logs the resolved formatstring with log_level
75
* @param log_level the level of the message
76
* @param format printf compatible format
78
void di_log (di_log_level_flags log_level, const char *format, ...) __attribute__ ((format(printf,2,3)));
80
* Logs the resolved formatstring with log_level
82
* @param log_level the level of the message
83
* @param format printf compatible format
84
* @param args variable arguments list
86
void di_vlog (di_log_level_flags log_level, const char *format, va_list args);
91
* @param log_levels levels
92
* @param log_func the log handler
93
* @param user_data data for log_func
95
unsigned int di_log_set_handler (di_log_level_flags log_levels, di_log_handler *log_func, void *user_data);
99
* Default log handler.
100
* Logs to STDOUT and STDERR.
102
di_log_handler_default,
104
* SYSLOG log handler.
107
di_log_handler_syslog;