diff --git a/CocoaHTTPServer.podspec.json b/CocoaHTTPServer.podspec.json index 6f09ea06..d22f4f93 100644 --- a/CocoaHTTPServer.podspec.json +++ b/CocoaHTTPServer.podspec.json @@ -38,7 +38,7 @@ ], "CocoaLumberjack": [ - + ">= 2.0.0" ] } -} \ No newline at end of file +} diff --git a/Core/HTTPLogging.h b/Core/HTTPLogging.h index 2e4bbcd0..649eab87 100644 --- a/Core/HTTPLogging.h +++ b/Core/HTTPLogging.h @@ -1,52 +1,64 @@ /** * In order to provide fast and flexible logging, this project uses Cocoa Lumberjack. - * + * * The Google Code page has a wealth of documentation if you have any questions. * https://github.com/robbiehanson/CocoaLumberjack - * + * * Here's what you need to know concerning how logging is setup for CocoaHTTPServer: - * + * * There are 4 log levels: * - Error * - Warning * - Info * - Verbose - * + * * In addition to this, there is a Trace flag that can be enabled. * When tracing is enabled, it spits out the methods that are being called. - * + * * Please note that tracing is separate from the log levels. * For example, one could set the log level to warning, and enable tracing. - * + * * All logging is asynchronous, except errors. * To use logging within your own custom files, follow the steps below. - * + * * Step 1: * Import this header in your implementation file: - * + * * #import "HTTPLogging.h" - * + * * Step 2: * Define your logging level in your implementation file: - * + * * // Log levels: off, error, warn, info, verbose * static const int httpLogLevel = HTTP_LOG_LEVEL_VERBOSE; - * + * * If you wish to enable tracing, you could do something like this: - * + * * // Debug levels: off, error, warn, info, verbose * static const int httpLogLevel = HTTP_LOG_LEVEL_INFO | HTTP_LOG_FLAG_TRACE; - * + * * Step 3: * Replace your NSLog statements with HTTPLog statements according to the severity of the message. - * + * * NSLog(@"Fatal error, no dohickey found!"); -> HTTPLogError(@"Fatal error, no dohickey found!"); - * + * * HTTPLog works exactly the same as NSLog. * This means you can pass it multiple variables just like NSLog. **/ -#import "DDLog.h" +#import + +#ifndef LOG_OBJC_MAYBE + // TODO: Remove these... and just use lib directly? + #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \ + do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0) + +#define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \ + LOG_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, ##__VA_ARGS__) + +#define LOG_C_MAYBE(async, lvl, flg, ctx, frmt, ...) \ + LOG_MAYBE(async, lvl, flg, ctx, __FUNCTION__, frmt, ##__VA_ARGS__) +#endif // Define logging context for every log message coming from the HTTP server. // The logging context can be extracted from the DDLogMessage from within the logging framework, @@ -69,7 +81,7 @@ // Setup fine grained logging. // The first 4 bits are being used by the standard log levels (0 - 3) -// +// // We're going to add tracing, but NOT as a log level. // Tracing can be turned on and off independently of log level.