//============================================================================== // This file is part of Master Password. // Copyright (c) 2011-2017, Maarten Billemont. // // 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. // // 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 . //============================================================================== #import #import "Pearl-Prefix.pch" #ifdef __OBJC__ #if TARGET_OS_IOS #import #elif TARGET_OS_OSX #import #endif #import #ifdef CRASHLYTICS #import #endif #if TARGET_OS_IOS #import "MPTypes.h" #import "MPiOSConfig.h" #elif TARGET_OS_OSX #import "MPTypes.h" #import "MPMacConfig.h" #endif #else #import #import #import #import #import #import #define 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) #define trc(format, ...) log( 0, format, ##__VA_ARGS__ ); #define dbg(format, ...) log( 1, format, ##__VA_ARGS__ ); #define inf(format, ...) log( 2, format, ##__VA_ARGS__ ); #define wrn(format, ...) log( 3, format, ##__VA_ARGS__ ); #define err(format, ...) log( 4, format, ##__VA_ARGS__ ); #define ftl(format, ...) log( 5, format, ##__VA_ARGS__ ); #endif