1 /* 2 Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> 3 Copyright (C) 2003, 2005 Rocky Bernstein <rocky@gnu.org> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 /** \file logging.h 20 * \brief Header to control logging and level of detail of output. 21 * 22 */ 23 24 #ifndef __VCD_LOGGING_H__ 25 #define __VCD_LOGGING_H__ 26 27 #include <libvcd/types.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif /* __cplusplus */ 32 33 /** 34 * The different log levels supported. 35 */ 36 typedef enum { 37 VCD_LOG_DEBUG = 1, /**< Debug-level messages - helps debug what's up. */ 38 VCD_LOG_INFO, /**< Informational - indicates perhaps something of 39 interest. */ 40 VCD_LOG_WARN, /**< Warning conditions - something that looks funny. */ 41 VCD_LOG_ERROR, /**< Error conditions - may terminate program. */ 42 VCD_LOG_ASSERT /**< Critical conditions - may abort program. */ 43 } vcd_log_level_t; 44 45 /** 46 * The place to save the preference concerning how much verbosity 47 * is desired. This is used by the internal default log handler, but 48 * it could be use by applications which provide their own log handler. 49 */ 50 extern vcd_log_level_t vcd_loglevel_default; 51 52 /** 53 * This type defines the signature of a log handler. For every 54 * message being logged, the handler will receive the log level and 55 * the message string. 56 * 57 * @see vcd_log_set_handler 58 * @see vcd_log_level_t 59 * 60 * @param level The log level. 61 * @param message The log message. 62 */ 63 typedef void (*vcd_log_handler_t) (vcd_log_level_t level, 64 const char message[]); 65 66 /** 67 * Set a custom log handler for libcdio. The return value is the log 68 * handler being replaced. If the provided parameter is NULL, then 69 * the handler will be reset to the default handler. 70 * 71 * @see vcd_log_handler_t 72 * 73 * @param new_handler The new log handler. 74 * @return The previous log handler. 75 */ 76 vcd_log_handler_t 77 vcd_log_set_handler (vcd_log_handler_t new_handler); 78 79 /** 80 * Handle an message with the given log level 81 * 82 * @see vcd_debug 83 * @see vcd_info 84 * @see vcd_warn 85 * @see vcd_error 86 87 * @param level The log level. 88 * @param format printf-style format string 89 * @param ... remaining arguments needed by format string 90 */ 91 void 92 vcd_log (vcd_log_level_t level, const char format[], ...) GNUC_PRINTF(2, 3); 93 94 /** 95 * Handle a debugging message. 96 * 97 * @see vcd_log for a more generic routine 98 */ 99 void 100 vcd_debug (const char format[], ...) GNUC_PRINTF(1,2); 101 102 /** 103 * Handle an informative message. 104 * 105 * @see vcd_log for a more generic routine 106 */ 107 void 108 vcd_info (const char format[], ...) GNUC_PRINTF(1,2); 109 110 /** 111 * Handle a warning message. 112 * 113 * @see vcd_log for a more generic routine 114 */ 115 void 116 vcd_warn (const char format[], ...) GNUC_PRINTF(1,2); 117 118 /** 119 * Handle an error message. 120 * 121 * @see vcd_log for a more generic routine. Execution is terminated. 122 */ 123 void 124 vcd_error (const char format[], ...) GNUC_PRINTF(1,2); 125 126 #ifdef __cplusplus 127 } 128 #endif /* __cplusplus */ 129 130 #endif /* __VCD_LOGGING_H__ */ 131 132 133 /* 134 * Local variables: 135 * c-file-style: "gnu" 136 * tab-width: 8 137 * indent-tabs-mode: nil 138 * End: 139 */ 140