Added logging APIs

This commit is contained in:
Pierre-Olivier Latour
2014-04-07 19:25:16 -07:00
parent dcbc0f96c5
commit 7ec8d5247a
2 changed files with 20 additions and 0 deletions

View File

@@ -67,6 +67,8 @@ NSString* GCDWebServerGetPrimaryIPv4Address(); // Returns IPv4 address of prima
@interface GCDWebServer (Extensions)
@property(nonatomic, readonly) NSURL* serverURL; // Only non-nil if server is running
@property(nonatomic, readonly) NSURL* bonjourServerURL; // Only non-nil if server is running and Bonjour registration is active
- (void)logWarning:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
- (void)logError:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
#if !TARGET_OS_IPHONE
- (BOOL)runWithPort:(NSUInteger)port; // Starts then automatically stops on SIGINT i.e. Ctrl-C (use on main thread only)
#endif

View File

@@ -483,6 +483,24 @@ static void _NetServiceClientCallBack(CFNetServiceRef service, CFStreamError* er
return nil;
}
- (void)logWarning:(NSString*)format, ... {
va_list arguments;
va_start(arguments, format);
NSString* message = [[NSString alloc] initWithFormat:format arguments:arguments];
va_end(arguments);
LOG_WARNING(@"%@", message);
ARC_RELEASE(message);
}
- (void)logError:(NSString*)format, ... {
va_list arguments;
va_start(arguments, format);
NSString* message = [[NSString alloc] initWithFormat:format arguments:arguments];
va_end(arguments);
LOG_ERROR(@"%@", message);
ARC_RELEASE(message);
}
#if !TARGET_OS_IPHONE
- (BOOL)runWithPort:(NSUInteger)port {