Closed
Description
@gliechtenstein and I had a brief chat about this today.
There should be a Jasonette logger that fires events for common actions, such as the ones below:
- Network Requests
- Network Responses
- Timer Creation/Start
- Timer Triggering Actions
I currently have an implementation of a very basic/simple version of this that simply logs these events to the xCode console using NSLog, but ideally a great implementation for Jasonette would include logging everything over Wifi without the need for xCode (node server) and ties into common analytics engines (Google Analytics, etc.).
Also, this implementation will need to be cross-platform and my simple example I provide is iOS only at the moment.
Example Log Calls:
// Example of a log call before a network request is made in JasonNetworkAction.m
[JasonetteLogger logNetworkRequest:method withUrl:url withData:self.options[@"data"] ];
// Example of a log call for a network response in JasonNetworkAction.m
[JasonetteLogger logNetworkResponse:method withUrl:url withDataType:dataType
withResponseObject:responseObject ];
Example JasonetteLogger:
// JasonetteLogger.m
// Very simple logger using NSLog to log app events.
//
// To turn off logging, set DEBUG to false in the xCode project file.
//
//
#import "JasonetteLogger.h"
@implementation JasonetteLogger
+ (void)logNetworkRequest: (NSString*)method withUrl: (NSString*)url withData:(NSDictionary*)data {
#if DEBUG
NSLog(@"🔵 Network Request: %@ 🔵", (method == NULL ? @"GET" : [method uppercaseString]));
NSLog(@"URL: %@", url);
if (method != NULL) {
NSLog(@"\n Data: %@ ", data);
}
#endif
}
+ (void)logNetworkResponse: (NSString*)method withUrl: (NSString*)url
withDataType: (NSDictionary*)dataType withResponseObject: (NSData*)responseObject {
#if DEBUG
NSLog(@"🔷 Network Response: %@ 🔷", (method == NULL ? @"GET" : [method uppercaseString]));
NSLog(@"DataType: %@", dataType);
NSLog(@"ResponseObject: \n %@", responseObject);
#endif
}
+ (void)logTimerStart: (NSString*)name isRepeating: (BOOL)repeating
withInterval: (NSTimeInterval)interval {
#if DEBUG
NSLog(@"⏱ Started %@Timer '%@' with interval '%d'⏱", repeating ? @"REPEATING " : @"",
name, (int)interval);
#endif
}
+ (void)logTimerActionTriggered: (NSString *)action{
#if DEBUG
NSLog(@"⏱ Timer Triggered Action:⏱");
NSLog(@"\n%@", action);
#endif
}
@end
Metadata
Metadata
Assignees
Labels
No labels