2
0
MasterPassword/platform-darwin/Source/MasterPassword-Prefix.pch

75 lines
2.7 KiB
Plaintext
Raw Normal View History

2017-04-05 20:56:22 +00:00
//==============================================================================
// This file is part of Master Password.
// Copyright (c) 2011-2017, Maarten Billemont.
2011-11-30 21:42:40 +00:00
//
2017-04-05 20:56:22 +00:00
// Master Password is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2011-11-30 21:42:40 +00:00
//
2017-04-05 20:56:22 +00:00
// Master Password is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You can find a copy of the GNU General Public License in the
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
//==============================================================================
2011-11-30 21:42:40 +00:00
#import <Availability.h>
#import "Pearl-Prefix.pch"
2011-11-30 21:42:40 +00:00
#ifdef __OBJC__
2017-04-05 16:53:56 +00:00
#if TARGET_OS_IOS
2012-06-08 21:46:13 +00:00
#import <UIKit/UIKit.h>
2017-04-05 16:53:56 +00:00
#elif TARGET_OS_OSX
#import <Cocoa/Cocoa.h>
2017-03-30 16:15:28 +00:00
#endif
2012-06-08 21:46:13 +00:00
#import <CoreData/CoreData.h>
2013-08-25 19:38:38 +00:00
#ifdef CRASHLYTICS
#import <Crashlytics/Crashlytics.h>
2013-08-25 19:38:38 +00:00
#endif
2017-03-30 16:15:28 +00:00
2017-04-05 16:53:56 +00:00
#if TARGET_OS_IOS
2012-06-08 21:46:13 +00:00
#import "MPTypes.h"
#import "MPiOSConfig.h"
2017-04-05 16:53:56 +00:00
#elif TARGET_OS_OSX
#import "MPTypes.h"
#import "MPMacConfig.h"
2017-03-30 16:15:28 +00:00
#endif
2011-11-30 21:42:40 +00:00
#else
#import <libgen.h>
#import <CoreFoundation/CFString.h>
#import <objc/runtime.h>
#import <objc/message.h>
#import <objc/NSObjCRuntime.h>
#import <stdlib.h>
2018-03-24 20:49:23 +00:00
#define mpw_log(level, format, ...) \
do { \
void (*_sendMsg)(id, SEL, CFStringRef, NSInteger, CFStringRef, NSUInteger, CFStringRef) = (void *)objc_msgSend; \
char *_msg = NULL; \
asprintf( &_msg, format, ##__VA_ARGS__ ); \
CFStringRef fileStr = CFStringCreateWithCString( NULL, basename( (char *)__FILE__ ), kCFStringEncodingUTF8 ); \
CFStringRef funcStr = CFStringCreateWithCString( NULL, __FUNCTION__, kCFStringEncodingUTF8 ); \
CFStringRef msgStr = CFStringCreateWithCString( NULL, _msg, kCFStringEncodingUTF8 ); \
_sendMsg( objc_msgSend( (id)objc_getClass( "PearlLogger" ), sel_getUid( "get" ) ), \
sel_getUid( "inFile:atLine:fromFunction:withLevel:text:" ), fileStr, __LINE__, funcStr, level, msgStr ); \
CFRelease( fileStr ); \
CFRelease( funcStr ); \
CFRelease( msgStr ); \
} while (0)
2018-03-24 20:49:23 +00:00
#define trc(format, ...) mpw_log( 0, format, ##__VA_ARGS__ );
#define dbg(format, ...) mpw_log( 1, format, ##__VA_ARGS__ );
#define inf(format, ...) mpw_log( 2, format, ##__VA_ARGS__ );
#define wrn(format, ...) mpw_log( 3, format, ##__VA_ARGS__ );
#define err(format, ...) mpw_log( 4, format, ##__VA_ARGS__ );
#define ftl(format, ...) mpw_log( 5, format, ##__VA_ARGS__ );
#endif