Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / bug.h
1 /************************************************************************************\
2
3     bug.h - debug support
4
5     (c) 2009 Copyright Hewlett-Packard Development Company, LP
6
7     Redistribution and use in source and binary forms, with or without
8     modification, are permitted provided that the following conditions
9     are met:
10     1. Redistributions of source code must retain the above copyright
11        notice, this list of conditions and the following disclaimer.
12     2. Redistributions in binary form must reproduce the above copyright
13        notice, this list of conditions and the following disclaimer in the
14        documentation and/or other materials provided with the distribution.
15     3. Neither the name of the Hewlett-Packard nor the names of its
16        contributors may be used to endorse or promote products derived
17        from this software without specific prior written permission.
18
19     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24     NOT LIMITED TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27     STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28     IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29     POSSIBILITY OF SUCH DAMAGE.
30
31 \************************************************************************************/
32
33 #ifndef _BUG_H
34 #define _BUG_H
35
36 #ifndef _GNU_SOURCE
37 #define _GNU_SOURCE
38 #endif
39
40 #define ADDITIONAL_LOG     1
41 #define SAVE_PCL_FILE      2
42 #define SAVE_INPUT_RASTERS 4
43 #define SEND_TO_PRINTER    8
44
45 #include <syslog.h>
46 #include <stdio.h>
47
48 #define _STRINGIZE(x) #x
49 #define STRINGIZE(x) _STRINGIZE(x)
50
51 #define BUG(args...) {syslog(LOG_ERR, __FILE__ " " STRINGIZE(__LINE__) ": " args); \
52 fprintf(stderr, __FILE__ " " STRINGIZE(__LINE__) ": " args);}
53
54 #define DBG_DUMP(data, size) sysdump((data), (size))
55 #if 1
56    #define DBG6(args...) DBG(6, __FILE__ " " STRINGIZE(__LINE__) ": " args)
57    #define DBG8(args...) DBG(8, __FILE__ " " STRINGIZE(__LINE__) ": " args)
58    #define DBG_SZ(args...) DBG(6, args)
59 #else
60    #define DBG6(args...) syslog(LOG_INFO, __FILE__ " " STRINGIZE(__LINE__) ": " args)
61    #define DBG8(args...) syslog(LOG_INFO, __FILE__ " " STRINGIZE(__LINE__) ": " args)
62    #define DBG_SZ(args...) syslog(LOG_INFO, args)
63 #endif
64
65 #endif /* _BUG_H */