-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMMDebugMacros.h
More file actions
50 lines (34 loc) · 1.33 KB
/
MMDebugMacros.h
File metadata and controls
50 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// Created by Michael May
// Copyright (c) 2012-2014 Michael May.
// MIT Licence. Use and enjoy.
// from http://iphoneincubator.com/blog/debugging/the-evolution-of-a-replacement-for-nslog
// DLog is almost a drop-in replacement for NSLog
// DLog();
// DLog(@"here");
// DLog(@"value: %d", x);
// Unfortunately this doesn't work DLog(aStringVariable); you have to do this instead DLog(@"%@", aStringVariable);
#ifndef _MMDebugMacros_h
#define _MMDebugMacros_h
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#define DAssert(assertion,message) NSAssert(assertion,message)
#define DAssertClass(aClass,anObject) NSAssert([anObject isKindOfClass:[aClass class]], @"object is not of class expected")
NS_INLINE void DAssertNotNil(id object)
{
NSCAssert(object != nil, @"Object was not and must not be");
}
NS_INLINE void DAssertPositiveNonZeroFloat(CGFloat value)
{
NSCAssert(value > 0, @"");
}
#else
#define DLog(...)
#define DAssert(assertion,message)
#define DAssertClass(aClass,anObject)
NS_INLINE void DAssertNotNil(id object) {}
NS_INLINE void DAssertPositiveNonZeroFloat(CGFloat value) {}
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#endif