Merge pull request #3660 from dreampiggy/project/log_into_oslog
Using os_log for our all log to replace the NSLog
This commit is contained in:
commit
c60958ca1c
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "SDImageCache.h"
|
#import "SDImageCache.h"
|
||||||
|
#import "SDInternalMacros.h"
|
||||||
#import "NSImage+Compatibility.h"
|
#import "NSImage+Compatibility.h"
|
||||||
#import "SDImageCodersManager.h"
|
#import "SDImageCodersManager.h"
|
||||||
#import "SDImageCoderHelper.h"
|
#import "SDImageCoderHelper.h"
|
||||||
|
@ -316,7 +317,7 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
NSError *error;
|
NSError *error;
|
||||||
extendedData = [NSKeyedArchiver archivedDataWithRootObject:extendedObject requiringSecureCoding:NO error:&error];
|
extendedData = [NSKeyedArchiver archivedDataWithRootObject:extendedObject requiringSecureCoding:NO error:&error];
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"NSKeyedArchiver archive failed with error: %@", error);
|
SD_LOG("NSKeyedArchiver archive failed with error: %@", error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@try {
|
@try {
|
||||||
|
@ -325,7 +326,7 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
extendedData = [NSKeyedArchiver archivedDataWithRootObject:extendedObject];
|
extendedData = [NSKeyedArchiver archivedDataWithRootObject:extendedObject];
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
} @catch (NSException *exception) {
|
} @catch (NSException *exception) {
|
||||||
NSLog(@"NSKeyedArchiver archive failed with exception: %@", exception);
|
SD_LOG("NSKeyedArchiver archive failed with exception: %@", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extendedData) {
|
if (extendedData) {
|
||||||
|
@ -574,7 +575,7 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
unarchiver.requiresSecureCoding = NO;
|
unarchiver.requiresSecureCoding = NO;
|
||||||
extendedObject = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error];
|
extendedObject = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error];
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"NSKeyedUnarchiver unarchive failed with error: %@", error);
|
SD_LOG("NSKeyedUnarchiver unarchive failed with error: %@", error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@try {
|
@try {
|
||||||
|
@ -583,7 +584,7 @@ static NSString * _defaultDiskCacheDirectory;
|
||||||
extendedObject = [NSKeyedUnarchiver unarchiveObjectWithData:extendedData];
|
extendedObject = [NSKeyedUnarchiver unarchiveObjectWithData:extendedData];
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
} @catch (NSException *exception) {
|
} @catch (NSException *exception) {
|
||||||
NSLog(@"NSKeyedUnarchiver unarchive failed with exception: %@", exception);
|
SD_LOG("NSKeyedUnarchiver unarchive failed with exception: %@", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
image.sd_extendedObject = extendedObject;
|
image.sd_extendedObject = extendedObject;
|
||||||
|
|
|
@ -238,7 +238,7 @@ static BOOL SDImageIOPNGPluginBuggyNeedWorkaround(void) {
|
||||||
// Correct value
|
// Correct value
|
||||||
isBuggy = NO;
|
isBuggy = NO;
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Detected the current OS's ImageIO PNG Decoder is buggy on indexed color PNG. Perform workaround solution...");
|
SD_LOG("Detected the current OS's ImageIO PNG Decoder is buggy on indexed color PNG. Perform workaround solution...");
|
||||||
isBuggy = YES;
|
isBuggy = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#import "SDImageGraphics.h"
|
#import "SDImageGraphics.h"
|
||||||
#import "SDGraphicsImageRenderer.h"
|
#import "SDGraphicsImageRenderer.h"
|
||||||
#import "NSBezierPath+SDRoundedCorners.h"
|
#import "NSBezierPath+SDRoundedCorners.h"
|
||||||
|
#import "SDInternalMacros.h"
|
||||||
#import <Accelerate/Accelerate.h>
|
#import <Accelerate/Accelerate.h>
|
||||||
#if SD_UIKIT || SD_MAC
|
#if SD_UIKIT || SD_MAC
|
||||||
#import <CoreImage/CoreImage.h>
|
#import <CoreImage/CoreImage.h>
|
||||||
|
@ -648,7 +649,7 @@ static inline CGImageRef _Nullable SDCreateCGImageFromCIImage(CIImage * _Nonnull
|
||||||
// Convert to color
|
// Convert to color
|
||||||
return SDGetColorFromRGBA(pixel, bitmapInfo, colorSpace);
|
return SDGetColorFromRGBA(pixel, bitmapInfo, colorSpace);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Unsupported components: %zu", components);
|
SD_LOG("Unsupported components: %zu", components);
|
||||||
CFRelease(data);
|
CFRelease(data);
|
||||||
CGImageRelease(imageRef);
|
CGImageRelease(imageRef);
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -732,7 +733,7 @@ static inline CGImageRef _Nullable SDCreateCGImageFromCIImage(CIImage * _Nonnull
|
||||||
Pixel_8888 pixel = {pixels[index], pixels[index+1], pixels[index+2], pixels[index+3]};
|
Pixel_8888 pixel = {pixels[index], pixels[index+1], pixels[index+2], pixels[index+3]};
|
||||||
color = SDGetColorFromRGBA(pixel, bitmapInfo, colorSpace);
|
color = SDGetColorFromRGBA(pixel, bitmapInfo, colorSpace);
|
||||||
} else {
|
} else {
|
||||||
NSLog(@"Unsupported components: %zu", components);
|
SD_LOG("Unsupported components: %zu", components);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (color) {
|
if (color) {
|
||||||
|
@ -796,12 +797,12 @@ static inline CGImageRef _Nullable SDCreateCGImageFromCIImage(CIImage * _Nonnull
|
||||||
vImage_Error err;
|
vImage_Error err;
|
||||||
err = vImageBuffer_InitWithCGImage(&effect, &format, NULL, imageRef, kvImageNoFlags); // vImage will convert to format we requests, no need `vImageConvert`
|
err = vImageBuffer_InitWithCGImage(&effect, &format, NULL, imageRef, kvImageNoFlags); // vImage will convert to format we requests, no need `vImageConvert`
|
||||||
if (err != kvImageNoError) {
|
if (err != kvImageNoError) {
|
||||||
NSLog(@"UIImage+Transform error: vImageBuffer_InitWithCGImage returned error code %zi for inputImage: %@", err, self);
|
SD_LOG("UIImage+Transform error: vImageBuffer_InitWithCGImage returned error code %zi for inputImage: %@", err, self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
err = vImageBuffer_Init(&scratch, effect.height, effect.width, format.bitsPerPixel, kvImageNoFlags);
|
err = vImageBuffer_Init(&scratch, effect.height, effect.width, format.bitsPerPixel, kvImageNoFlags);
|
||||||
if (err != kvImageNoError) {
|
if (err != kvImageNoError) {
|
||||||
NSLog(@"UIImage+Transform error: vImageBuffer_Init returned error code %zi for inputImage: %@", err, self);
|
SD_LOG("UIImage+Transform error: vImageBuffer_Init returned error code %zi for inputImage: %@", err, self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <os/lock.h>
|
#import <os/lock.h>
|
||||||
#import <libkern/OSAtomic.h>
|
#import <libkern/OSAtomic.h>
|
||||||
|
#import <os/log.h>
|
||||||
#import "SDmetamacros.h"
|
#import "SDmetamacros.h"
|
||||||
|
|
||||||
#define SD_USE_OS_UNFAIR_LOCK TARGET_OS_MACCATALYST ||\
|
#define SD_USE_OS_UNFAIR_LOCK TARGET_OS_MACCATALYST ||\
|
||||||
|
@ -78,6 +79,13 @@ else OSSpinLockUnlock(&lock##_deprecated);
|
||||||
#define SD_SEL_SPI(name) NSSelectorFromString([NSString stringWithFormat:@"_%@", SD_NSSTRING(name)])
|
#define SD_SEL_SPI(name) NSSelectorFromString([NSString stringWithFormat:@"_%@", SD_NSSTRING(name)])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern os_log_t sd_getDefaultLog(void);
|
||||||
|
|
||||||
|
#ifndef SD_LOG
|
||||||
|
#define SD_LOG(_log, ...) if (@available(iOS 10.0, tvOS 10.0, macOS 10.12, watchOS 3.0, *)) os_log(sd_getDefaultLog(), _log, ##__VA_ARGS__); \
|
||||||
|
else NSLog(@(_log), ##__VA_ARGS__);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef weakify
|
#ifndef weakify
|
||||||
#define weakify(...) \
|
#define weakify(...) \
|
||||||
sd_keywordify \
|
sd_keywordify \
|
||||||
|
|
|
@ -8,6 +8,15 @@
|
||||||
|
|
||||||
#import "SDInternalMacros.h"
|
#import "SDInternalMacros.h"
|
||||||
|
|
||||||
|
os_log_t sd_getDefaultLog(void) {
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
static os_log_t log;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
log = os_log_create("com.hackemist.SDWebImage", "Default");
|
||||||
|
});
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
void sd_executeCleanupBlock (__strong sd_cleanupBlock_t *block) {
|
void sd_executeCleanupBlock (__strong sd_cleanupBlock_t *block) {
|
||||||
(*block)();
|
(*block)();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue