debug.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010-2011 Vojtech Horky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00035 #ifndef LIBUSB_DEBUG_H_
00036 #define LIBUSB_DEBUG_H_
00037 #include <stdio.h>
00038 #include <inttypes.h>
00039 #include <usb/usb.h>
00040 #include <assert.h>
00041 
00042 void usb_dump_standard_descriptor(FILE *, const char *, const char *,
00043     const uint8_t *, size_t);
00044 
00046 typedef enum {
00050         USB_LOG_LEVEL_FATAL,
00051 
00056         USB_LOG_LEVEL_ERROR,
00057 
00061         USB_LOG_LEVEL_WARNING,
00062 
00070         USB_LOG_LEVEL_INFO,
00071 
00073         USB_LOG_LEVEL_DEBUG,
00074 
00076         USB_LOG_LEVEL_DEBUG2,
00077 
00079         USB_LOG_LEVEL_MAX
00080 } usb_log_level_t;
00081 
00083 #ifdef CONFIG_USB_RELEASE_BUILD
00084 #  define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_INFO
00085 #else
00086 #  define USB_LOG_LEVEL_DEFAULT USB_LOG_LEVEL_DEBUG
00087 #endif
00088 
00089 void usb_log_enable(usb_log_level_t, const char *);
00090 
00091 void usb_log_printf(usb_log_level_t, const char *, ...)
00092         PRINTF_ATTRIBUTE(2, 3);
00093 
00095 #define usb_log_fatal(format, ...) \
00096         usb_log_printf(USB_LOG_LEVEL_FATAL, format, ##__VA_ARGS__)
00097 
00099 #define usb_log_error(format, ...) \
00100         usb_log_printf(USB_LOG_LEVEL_ERROR, format, ##__VA_ARGS__)
00101 
00103 #define usb_log_warning(format, ...) \
00104         usb_log_printf(USB_LOG_LEVEL_WARNING, format, ##__VA_ARGS__)
00105 
00107 #define usb_log_info(format, ...) \
00108         usb_log_printf(USB_LOG_LEVEL_INFO, format, ##__VA_ARGS__)
00109 
00111 #define usb_log_debug(format, ...) \
00112         usb_log_printf(USB_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__)
00113 
00115 #define usb_log_debug2(format, ...) \
00116         usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
00117 
00118 const char *usb_debug_str_buffer(const uint8_t *, size_t, size_t);
00119 
00120 
00121 #endif
00122 

Generated on Thu Jun 2 07:45:42 2011 for HelenOS/USB by  doxygen 1.4.7