Jamoma API  0.6.0.a19
CALogMacros.h
1 /* Copyright 2007 Apple Inc. All Rights Reserved.
2 
3  Disclaimer: IMPORTANT: This Apple software is supplied to you by
4  Apple Inc. ("Apple") in consideration of your agreement to the
5  following terms, and your use, installation, modification or
6  redistribution of this Apple software constitutes acceptance of these
7  terms. If you do not agree with these terms, please do not use,
8  install, modify or redistribute this Apple software.
9 
10  In consideration of your agreement to abide by the following terms, and
11  subject to these terms, Apple grants you a personal, non-exclusive
12  license, under Apple's copyrights in this original Apple software (the
13  "Apple Software"), to use, reproduce, modify and redistribute the Apple
14  Software, with or without modifications, in source and/or binary forms;
15  provided that if you redistribute the Apple Software in its entirety and
16  without modifications, you must retain this notice and the following
17  text and disclaimers in all such redistributions of the Apple Software.
18  Neither the name, trademarks, service marks or logos of Apple Inc.
19  may be used to endorse or promote products derived from the Apple
20  Software without specific prior written permission from Apple. Except
21  as expressly stated in this notice, no other rights or licenses, express
22  or implied, are granted by Apple herein, including but not limited to
23  any patent rights that may be infringed by your derivative works or by
24  other works in which the Apple Software may be incorporated.
25 
26  The Apple Software is provided by Apple on an "AS IS" basis. APPLE
27  MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
28  THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
29  FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
30  OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
31 
32  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
33  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
36  MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
37  AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
38  STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
39  POSSIBILITY OF SUCH DAMAGE.
40 */
41 #if !defined(__CALogMacros_h__)
42 #define __CALogMacros_h__
43 
44 //=============================================================================
45 // Log Macros
46 //=============================================================================
47 
48 #if CoreAudio_Debug
49 
50  #include "CADebugMacros.h"
51  #include "CADebugPrintf.h"
52  #include <stdio.h>
53  #include <string.h>
54 
55  #define PrintLine(msg) DebugPrintfRtn(DebugPrintfFileComma "%s\n", (msg))
56 
57  #define PrintBool(msg, b) DebugPrintfRtn(DebugPrintfFileComma "%s%s\n", (msg), (b) ? "true" : "false")
58  #define PrintIndexedBool(msg, i, b) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: %s\n", (msg), (long)(i), (b) ? "true" : "false")
59 
60  #define PrintToggle(msg, b) DebugPrintfRtn(DebugPrintfFileComma "%s%s\n", (msg), (b) ? "on" : "off")
61  #define PrintIndexedToggle(msg, i, b) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: %s\n", (msg), (long)(i), (b) ? "on" : "off")
62 
63  #define PrintInt(msg, n) DebugPrintfRtn(DebugPrintfFileComma "%s%ld\n", (msg), (long)(n))
64  #define PrintIndexedInt(msg, i, n) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: %ld\n", (msg), (long)(i), (long)(n))
65 
66  #define PrintHex(msg, n) DebugPrintfRtn(DebugPrintfFileComma "%s0x%lX\n", (msg), (unsigned long)(n))
67  #define PrintIndexedHex(msg, i, n) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: 0x%lX\n", (msg), (long)(i), (unsigned long)(n))
68 
69  #define PrintFloat(msg, f) DebugPrintfRtn(DebugPrintfFileComma "%s%.6f\n", (msg), (f))
70  #define PrintIndexedFloat(msg, i, f) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: %.6f\n", (msg), (long)(i), (f))
71  #define PrintFloatIndexedFloat(msg, i, f) DebugPrintfRtn(DebugPrintfFileComma " %s %.6f: %.6f\n", (msg), (i), (f))
72 
73  #define PrintString(msg, s) DebugPrintfRtn(DebugPrintfFileComma "%s%s\n", (msg), (s))
74  #define PrintIndexedString(msg, i, s) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: %s\n", (msg), (long)(i), (s))
75 
76  #define PrintPointer(msg, p) DebugPrintfRtn(DebugPrintfFileComma "%s%p\n", (msg), (p))
77  #define PrintIndexedPointer(msg, i, p) DebugPrintfRtn(DebugPrintfFileComma " %s %ld: %p\n", (msg), (long)(i), (p))
78 
79  #define Print4CharCode(msg, c) { \
80  UInt32 __4CC_number = (c); \
81  char __4CC_string[5] = CA4CCToCString(__4CC_number); \
82  DebugPrintfRtn(DebugPrintfFileComma "%s'%s'\n", (msg), __4CC_string); \
83  }
84  #define PrintIndexed4CharCode(msg, i, c) { \
85  UInt32 __4CC_number = (c); \
86  char __4CC_string[5] = CA4CCToCString(__4CC_number); \
87  DebugPrintfRtn(DebugPrintfFileComma " %s %ld: '%s'\n", (msg), (long)(i), __4CC_string); \
88  }
89 
90  #define ErrorLine(s) DebugPrintfRtn(DebugPrintfFileComma "%s\n", (s))
91  #define OSErrorLine(s, e) { \
92  OSStatus __err_number = (e); \
93  char __err_string[5] = CA4CCToCString(__err_number); \
94  DebugPrintfRtn(DebugPrintfFileComma "%s, OSStatus code: %s\n", (s), __err_string); \
95  }
96 
97  #define MessageIfOSError(e, s) if((e) != 0) { OSErrorLine(s, e); }
98  #define MessageIfNULL(p, s) if((p) == 0) { ErrorLine(s); }
99 
100 #else
101 
102  #define PrintLine(msg)
103 
104  #define PrintBool(msg, b) (b)
105  #define PrintIndexedBool(msg, i, b) (b)
106 
107  #define PrintInt(msg, n) (n)
108  #define PrintIndexedInt(msg, i, n) (n)
109 
110  #define PrintHex(msg, n) (n)
111  #define PrintIndexedHex(msg, i, n) (n)
112 
113  #define PrintFloat(msg, f) (f)
114  #define PrintIndexedFloat(msg, i, f) (f)
115  #define PrintFloatIndexedFloat(msg, i, f) (f)
116 
117  #define PrintString(msg, s) (s)
118  #define PrintIndexedString(msg, i, s) (s)
119 
120  #define PrintPointer(msg, p) (p)
121  #define PrintIndexedPointer(msg, i, p) (p)
122 
123  #define Print4CharCode(msg, c) (c)
124  #define PrintIndexed4CharCode(msg, i, c) (c)
125 
126  #define ErrorLine(s) (s)
127  #define OSErrorLine(s, e) (e)
128 
129  #define MessageIfOSError(e, s) (e)
130  #define MessageIfNULL(p, s) (p)
131 
132 #endif // CoreAudio_Debug
133 
134 #endif