1 /*
2  * This file is part of OpenCorsairLink.
3  * Copyright (C) 2017-2019  Sean Nelson <audiohacked@gmail.com>
4 
5  * OpenCorsairLink 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  * any later version.
9 
10  * OpenCorsairLink 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 OpenCorsairLink.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _PRINT_H
20 #define _PRINT_H
21 
22 #include <stdint.h>
23 
24 enum msglevel
25 {
26     MSG_ERROR = 1,
27     MSG_WARN = 2,
28     MSG_MACHINE = 3,
29     MSG_INFO = 4,
30     MSG_DEBUG = 5,
31     MSG_DEBUG2 = 6,
32     MSG_SPEW = 7,
33 };
34 
35 extern uint8_t verbose;
36 
37 int
38 print( enum msglevel level, const char* fmt, ... ) __attribute__( ( format( printf, 2, 3 ) ) );
39 int
40 dump_packet( uint8_t* packet, int size );
41 
42 #define msg_err( ... ) print( MSG_ERROR, __VA_ARGS__ )
43 #define msg_warn( ... ) print( MSG_WARN, __VA_ARGS__ )
44 #define msg_info( ... ) print( MSG_INFO, __VA_ARGS__ )
45 #define msg_debug( ... ) print( MSG_DEBUG, __VA_ARGS__ )
46 #define msg_debug2( ... ) print( MSG_DEBUG2, __VA_ARGS__ )
47 #define msg_spew( ... ) print( MSG_SPEW, __VA_ARGS__ )
48 
49 #define msg_machine( ... ) print( MSG_MACHINE, __VA_ARGS__ )
50 
51 #endif
52