Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Release v1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarbo committed Aug 26, 2022
1 parent aa8fc89 commit d69bc7d
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Glassfy.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Glassfy"
s.version = "1.3.1"
s.version = "1.3.2"
s.summary = "Subscription and in-app-purchase service."
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.source = { :git => "https://github.com/glassfy/ios-sdk.git", :tag => s.version.to_s }
Expand Down
4 changes: 2 additions & 2 deletions Glassfy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.1;
MARKETING_VERSION = 1.3.2;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -793,7 +793,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.3.1;
MARKETING_VERSION = 1.3.2;
PRODUCT_BUNDLE_IDENTIFIER = net.glassfy.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ Our SDK can be easly integrated through Cocoapods or Swift Package Manager
#### Integrate using Cocoapods
Add the pod to your Podfile:

```pod 'Glassfy', '~> 1.3.1'```
```pod 'Glassfy', '~> 1.3.2'```

Then, run the following command:

```pod install```

#### Integrate using Swift Package Manager
You can use Swift Package Manager to integrate Glassfy SDK in your application. In your Xcode project select file -> Add Packages... and enter the Glassfy GitHub URL: https://github.com/glassfy/ios-sdk. Set the version “Up to Next Major” to the version you want to use.
You can use Swift Package Manager to integrate Glassfy SDK in your application.
- In your Xcode project select file -> Add Packages...
- Enter the Glassfy GitHub URL: `https://github.com/glassfy/ios-sdk`.
- Set the version “Up to Next Major” to the version you want to use.

### More Info

Expand Down
11 changes: 6 additions & 5 deletions Source/GYAPIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,16 @@ - (void)callApiWithRequest:(NSURLRequest *)req
{
NSString *reqSignature = [GYUtils requestSignature:req];
if (self.completions[reqSignature]) {
GYLog(@"API [%@] IN FLIGHT %@?%@", [reqSignature substringToIndex:3], req.URL.lastPathComponent, req.URL.query);
GYLog(@"API [%@] In Progress", [reqSignature substringToIndex:3]);
if (block) {
NSMutableArray *arr = self.completions[reqSignature];
[arr addObject:[block copy]];
}
return;
}
else {
GYLog(@"API [%@] START %@?%@", [reqSignature substringToIndex:3], req.URL.lastPathComponent, req.URL.query);
GYLog(@"API [%@] Start\t/%@", [reqSignature substringToIndex:3], req.URL.lastPathComponent);
GYLogInfo(@"API [%@] Query:\n?%@", [reqSignature substringToIndex:3], req.URL.query);
if (block) {
self.completions[reqSignature] = [NSMutableArray arrayWithObject:[block copy]];
}
Expand All @@ -497,21 +498,21 @@ - (void)callApiWithRequest:(NSURLRequest *)req
res = [[(Class)R alloc] initWithObject:obj error:&err];
}

GYLogInfo(@"API [%@] RESPONSE: %@", [reqSignature substringToIndex:3], [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
GYLogInfo(@"API [%@] Response:\n%@", [reqSignature substringToIndex:3], err ? [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] : [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:obj options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding] );

dispatch_async(Glassfy.shared.glqueue, ^{
NSArray *completions = weakSelf.completions[reqSignature];
weakSelf.completions[reqSignature] = nil;
for (GYBaseAPICompletion c in completions) {
if (err) {
GYLogErr(@"API [%@] ERROR: %@", [reqSignature substringToIndex:3], err);
GYLogErr(@"API [%@] Error: %@", [reqSignature substringToIndex:3], err);

c(nil, err);
}
else {
c(res, nil);
}
GYLog(@"API [%@] END", [reqSignature substringToIndex:3]);
GYLog(@"API [%@] End", [reqSignature substringToIndex:3]);
}
});
}] resume];
Expand Down
39 changes: 23 additions & 16 deletions Source/GYLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,32 @@
NS_ASSUME_NONNULL_BEGIN

#ifdef DEBUG

#define GYLog(...) GYLogDebug(__VA_ARGS__)
#define GYLogErr(...) [GYLogger logErr:__VA_ARGS__]
#define GYLogDebug(...) [GYLogger logDebug:__VA_ARGS__]
#define GYLogInfo(...) [GYLogger logInfo:__VA_ARGS__]
#define GYLogHint(...) [GYLogger logHint:__VA_ARGS__]
#define GYLogSetLevel(level) [GYLogger setLogLevel:level]

@interface GYLogger: NSObject
#define GYLog(...) GYLogDebug(__VA_ARGS__)
#define GYLogErr(...) [GYLogger logErr:__VA_ARGS__]
#define GYLogDebug(...) [GYLogger logDebug:__VA_ARGS__]
#define GYLogInfo(...) [GYLogger logInfo:__VA_ARGS__]
#define GYLogSetLevel(level) [GYLogger setLogLevel:level]

+ (void)logErr:(nullable NSString *)format, ...;
+ (void)logDebug:(nullable NSString *)format, ...;
+ (void)logInfo:(nullable NSString *)format, ...;

+ (void)setLogLevel:(GYLogLevel)level;
+ (void)logErr:(nullable NSString *)format, ...;
+ (void)logDebug:(nullable NSString *)format, ...;
+ (void)logInfo:(nullable NSString *)format, ...;
+ (void)logHint:(nullable NSString *)format, ...;

+ (void)setLogLevel:(GYLogLevel)level;
@end

#else
#define GYLog(...) do{ }while(0)
#define GYLogErr(...) do{ }while(0)
#define GYLogDebug(...) do{ }while(0)
#define GYLogInfo(...) do{ }while(0)
#define GYLogSetLevel(level) do{ }while(0)

#define GYLog(...) do{ }while(0)
#define GYLogErr(...) do{ }while(0)
#define GYLogDebug(...) do{ }while(0)
#define GYLogInfo(...) do{ }while(0)
#define GYLogHint(...) do{ }while(0)
#define GYLogSetLevel(level) do{ }while(0)

#endif

NS_ASSUME_NONNULL_END
99 changes: 76 additions & 23 deletions Source/GYLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#ifdef DEBUG

#define LogFormat @"[Glassfy SDK] (%@):\t%@"
#define LogFormat "%s\t%s"

#import "GYLogger.h"
#import <os/log.h>

@interface GYLogger()
@property(nonatomic, strong) dispatch_queue_t logQueue;
@property(atomic, assign) unsigned long long agId;
@property(nonatomic, strong) os_log_t logGlassfy;
@end


Expand All @@ -28,35 +28,88 @@ + (void)setLogLevel:(GYLogLevel)level

+ (void)logErr:(NSString *)format,...
{
if (format && (logLevel & GYLogFlagError)) {
va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
NSLog(LogFormat, @"ERROR", logString);
va_end(args);
}
if (!format) { return; }
os_log_t log = (logLevel & GYLogFlagError) ? self.shared.logGlassfy : OS_LOG_DISABLED;

va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

[[logString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
os_log(log, LogFormat, idx ? " " : "🛑", obj.UTF8String);
}];
// os_log_error(self.shared.logGlassfy, LogFormat, "❗️", logString.UTF8String);
}

+ (void)logDebug:(NSString *)format,...
{
if (format && (logLevel & GYLogFlagDebug)) {
va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
NSLog(LogFormat, @"debug", logString);
va_end(args);
}
if (!format) { return; }
os_log_t log = (logLevel & GYLogFlagDebug) ? self.shared.logGlassfy : OS_LOG_DISABLED;

va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

[[logString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
os_log(log, LogFormat, idx ? " " : "🔨", obj.UTF8String);
}];
// os_log_debug(log, LogFormat, "🔨", logString.UTF8String);
}

+ (void)logInfo:(NSString *)format,...
{
if (format && (logLevel & GYLogFlagInfo)) {
va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
NSLog(LogFormat, @"info", logString);
va_end(args);
if (!format) { return; }
os_log_t log = (logLevel & GYLogFlagInfo) ? self.shared.logGlassfy : OS_LOG_DISABLED;

va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

[[logString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
os_log(log, LogFormat, idx ? " " : "📋", obj.UTF8String);
}];
// os_log_info(log, LogFormat, "📋", logString.UTF8String);
}

+ (void)logHint:(nullable NSString *)format, ...
{
if (!format) { return; }
os_log_t log = self.shared.logGlassfy;

va_list args;
va_start(args, format);
NSString *logString = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

[[logString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL *stop) {
os_log(log, LogFormat, idx ? " " : "🧐", obj.UTF8String);
}];
// os_log_info(log, LogFormat, "🧐", logString.UTF8String);
}


#pragma mark - private

- (instancetype)init
{
self = [super init];
if (self) {
self.logGlassfy = os_log_create("net.glassfy.sdk", "Glassfy SDK");
}
return self;
}

+ (GYLogger *)shared
{
static GYLogger *sharedInstance = nil;
static dispatch_once_t initOnceToken;
dispatch_once(&initOnceToken, ^{
sharedInstance = [[GYLogger alloc] init];
});
return sharedInstance;
}

@end
Expand Down
Loading

0 comments on commit d69bc7d

Please sign in to comment.