Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CocoaLumberjack 2.x #141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CocoaHTTPServer.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

],
"CocoaLumberjack": [

">= 2.0.0"
]
}
}
}
46 changes: 29 additions & 17 deletions Core/HTTPLogging.h
Original file line number Diff line number Diff line change
@@ -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 <CocoaLumberjack/CocoaLumberjack.h>

#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,
Expand All @@ -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.

Expand Down