mmlib/mmat: replace some variables by literal constants
[mmondor.git] / mmsoftware / mmlib / mmlog.h
1 /* $Id: mmlog.h,v 1.17 2007/12/05 23:47:56 mmondor Exp $ */
2
3 /*
4 * Copyright (C) 2000, 2004, 2007, Matthew Mondor
5 * All rights reserved.
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Matthew Mondor.
18 * 4. The name of Matthew Mondor may not be used to endorse or promote
19 * products derived from this software without specific prior written
20 * permission.
21 * 5. Redistribution of source code may not be released under the terms of
22 * any GNU Public License derivate.
23 *
24 * THIS SOFTWARE IS PROVIDED BY MATTHEW MONDOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL MATTHEW MONDOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36
37 #ifndef MMLOG_H
38 #define MMLOG_H
39
40
41 /*
42 * So that debugging messages can use DEBUG_PRINTF() and not be included when
43 * we don't need them.
44 */
45 #ifdef DEBUG
46
47 /* Allows to print a debugging message */
48 #define DEBUG_PRINTF(s...) mmdebug(__FILE__, __func__, __LINE__, s)
49
50 /*
51 * Similar to assert, but won't exit the application, just evaluates to TRUE
52 * if condition is TRUE, or always to TRUE if debugging is disabled.
53 * I.E. if (DEBUG_TRUE(condition)) ...
54 */
55 #define DEBUG_TRUE(c) (c)
56
57 /*
58 * Similar to DEBUG_TRUE(), but evaluates to TRUE if condition is TRUE, or
59 * always to FALSE if debugging is disabled.
60 * I.E. if (DEBUG_FALSE(condition)) ...
61 */
62 #define DEBUG_FALSE(c) (c)
63
64 /*
65 * Macro similar to assert(3) but which does not exit the application. Will
66 * instead log the condition.
67 */
68 #ifdef DEBUG_ASSERT_ABORT
69 #define DEBUG_ASSERT(c) if (!(c)) \
70 mmdebug2(__FILE__, __func__, __LINE__, "DEBUG_ASSERT(" #c ") == %d", c);
71 #else
72 #define DEBUG_ASSERT(c) if (!(c)) \
73 mmdebug(__FILE__, __func__, __LINE__, "DEBUG_ASSERT(" #c ") == %d", c);
74 #endif
75
76 #else
77
78 #define DEBUG_PRINTF(f, s...) ;
79 #define DEBUG_TRUE(c) /* CONSTCOND */1
80 #define DEBUG_FALSE(c) /* CONSTCOND */0
81 #define DEBUG_ASSERT(c) ;
82
83 #endif
84
85
86 extern void mmsyslog(int, int, const char *, ...);
87 extern void mmdebug(const char *, const char *, int, const char *, ...);
88
89
90 #endif