~ubuntu-branches/ubuntu/feisty/libdebian-installer/feisty

« back to all changes in this revision

Viewing changes to include/debian-installer/log.h

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2004-06-15 12:41:12 UTC
  • Revision ID: james.westby@ubuntu.com-20040615124112-irrmriyd8d6s067u
Tags: 0.29
* Joey Hess
  - Re-enable character device mapping. Though it often gets it wrong, the
    cases where it gets it right are used by prebaseconfig.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 *
 
20
 * $Id: log.h 11699 2004-03-22 09:35:42Z waldi $
 
21
 */
 
22
 
 
23
#ifndef DEBIAN_INSTALLER__LOG_H
 
24
#define DEBIAN_INSTALLER__LOG_H
 
25
 
 
26
#include <stdarg.h>
 
27
 
 
28
/**
 
29
 * @addtogroup di_log
 
30
 * @{
 
31
 */
 
32
 
 
33
/**
 
34
 * @brief Log levels and other flags
 
35
 */
 
36
typedef enum
 
37
{
 
38
  DI_LOG_FLAG_FATAL             = 1 << 1,       /**< flag as fatal */
 
39
 
 
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 */
 
47
 
 
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 */
 
50
}
 
51
di_log_level_flags;
 
52
 
 
53
typedef void di_log_handler (di_log_level_flags log_level, const char *message, void *user_data);
 
54
 
 
55
/**
 
56
 * logs an error
 
57
 */
 
58
#define di_error(format...) di_log (DI_LOG_LEVEL_ERROR, format)
 
59
/**
 
60
 * logs a warning
 
61
 */
 
62
#define di_warning(format...) di_log (DI_LOG_LEVEL_WARNING, format)
 
63
/**
 
64
 * logs information
 
65
 */
 
66
#define di_info(format...) di_log (DI_LOG_LEVEL_INFO, format)
 
67
/**
 
68
 * logs debug info
 
69
 */
 
70
#define di_debug(format...) di_log (DI_LOG_LEVEL_DEBUG, format)
 
71
 
 
72
/**
 
73
 * Logs the resolved formatstring with log_level
 
74
 *
 
75
 * @param log_level the level of the message
 
76
 * @param format printf compatible format
 
77
 */
 
78
void di_log (di_log_level_flags log_level, const char *format, ...) __attribute__ ((format(printf,2,3)));
 
79
/**
 
80
 * Logs the resolved formatstring with log_level
 
81
 *
 
82
 * @param log_level the level of the message
 
83
 * @param format printf compatible format
 
84
 * @param args variable arguments list
 
85
 */
 
86
void di_vlog (di_log_level_flags log_level, const char *format, va_list args);
 
87
 
 
88
/**
 
89
 * Sets a log handler
 
90
 *
 
91
 * @param log_levels levels
 
92
 * @param log_func the log handler
 
93
 * @param user_data data for log_func
 
94
 */
 
95
unsigned int di_log_set_handler (di_log_level_flags log_levels, di_log_handler *log_func, void *user_data);
 
96
 
 
97
di_log_handler
 
98
  /**
 
99
   * Default log handler.
 
100
   * Logs to STDOUT and STDERR.
 
101
   */
 
102
  di_log_handler_default,
 
103
  /**
 
104
   * SYSLOG log handler.
 
105
   * Logs to SYSLOG.
 
106
   */
 
107
  di_log_handler_syslog;
 
108
 
 
109
/** @} */
 
110
#endif