Skip to content

Commit

Permalink
Switch to an embedded variant of LibComponentLogging with prefix RK
Browse files Browse the repository at this point in the history
  • Loading branch information
aharren committed Sep 27, 2012
1 parent b80f083 commit bc7c65f
Show file tree
Hide file tree
Showing 40 changed files with 357 additions and 559 deletions.
2 changes: 1 addition & 1 deletion Code/CoreData/RKEntityByAttributeCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreDataCache
#define RKLogComponent RKlcl_cRestKitCoreDataCache

@interface RKEntityByAttributeCache ()
@property (nonatomic, strong) NSMutableDictionary *attributeValuesToObjectIDs;
Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKEntityMapping.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

// Implemented in RKMappingOperation
BOOL RKValueIsEqualToValue(id sourceValue, id destinationValue);
Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKFetchRequestManagedObjectCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@implementation RKFetchRequestManagedObjectCache

Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKInMemoryManagedObjectCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

//static NSString * const RKInMemoryObjectManagedObjectCacheThreadDictionaryKey = @"RKInMemoryObjectManagedObjectCacheThreadDictionaryKey";

Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKManagedObjectImporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@interface RKManagedObjectImporter ()
@property (nonatomic, strong, readwrite) NSManagedObjectModel *managedObjectModel;
Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKManagedObjectStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

NSString * const RKSQLitePersistentStoreSeedDatabasePathOption = @"RKSQLitePersistentStoreSeedDatabasePathOption";
NSString * const RKManagedObjectStoreDidFailSaveNotification = @"RKManagedObjectStoreDidFailSaveNotification";
Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKManagedObjectThreadSafeInvocation.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@interface RKManagedObjectThreadSafeInvocation ()
@property (nonatomic, strong) NSMutableDictionary *argumentKeyPaths;
Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKObjectPropertyInspector+CoreData.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@implementation RKPropertyInspector (CoreData)

Expand Down
2 changes: 1 addition & 1 deletion Code/CoreData/RKRelationshipConnectionOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@interface RKRelationshipConnectionOperation ()
@property (nonatomic, strong, readwrite) NSManagedObject *managedObject;
Expand Down
10 changes: 5 additions & 5 deletions Code/Network/RKHTTPRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

#import "RKHTTPRequestOperation.h"
#import "RKLog.h"
#import "lcl.h"
#import "lcl_RK.h"
#import "RKHTTPUtilities.h"
#import "RKMIMETypes.h"

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitNetwork
#define RKLogComponent RKlcl_cRestKitNetwork

@interface RKHTTPRequestOperationLogger : NSObject

Expand Down Expand Up @@ -81,7 +81,7 @@ - (void)HTTPOperationDidStart:(NSNotification *)notification
body = [NSString stringWithUTF8String:[[operation.request HTTPBody] bytes]];
}

if ((_lcl_component_level[(__lcl_log_symbol(lcl_cRestKitNetwork))]) >= (__lcl_log_symbol(lcl_vTrace))) {
if ((_RKlcl_component_level[(__RKlcl_log_symbol(RKlcl_cRestKitNetwork))]) >= (__RKlcl_log_symbol(RKlcl_vTrace))) {
RKLogTrace(@"%@ '%@':\nrequest.headers=%@\nrequest.body=%@", [operation.request HTTPMethod], [[operation.request URL] absoluteString], [operation.request allHTTPHeaderFields], body);
} else {
RKLogInfo(@"%@ '%@'", [operation.request HTTPMethod], [[operation.request URL] absoluteString]);
Expand All @@ -92,13 +92,13 @@ - (void)HTTPOperationDidFinish:(NSNotification *)notification
{
RKHTTPRequestOperation *operation = [notification object];
if (operation.error) {
if ((_lcl_component_level[(__lcl_log_symbol(lcl_cRestKitNetwork))]) >= (__lcl_log_symbol(lcl_vTrace))) {
if ((_RKlcl_component_level[(__RKlcl_log_symbol(RKlcl_cRestKitNetwork))]) >= (__RKlcl_log_symbol(RKlcl_vTrace))) {
RKLogError(@"%@ '%@' (%ld):\nerror=%@\nresponse.body=%@", [operation.request HTTPMethod], [[operation.request URL] absoluteString], (long)[operation.response statusCode], operation.error, operation.responseString);
} else {
RKLogError(@"%@ '%@' (%ld): %@", [operation.request HTTPMethod], [[operation.request URL] absoluteString], (long)[operation.response statusCode], operation.error);
}
} else {
if ((_lcl_component_level[(__lcl_log_symbol(lcl_cRestKitNetwork))]) >= (__lcl_log_symbol(lcl_vTrace))) {
if ((_RKlcl_component_level[(__RKlcl_log_symbol(RKlcl_cRestKitNetwork))]) >= (__RKlcl_log_symbol(RKlcl_vTrace))) {
RKLogTrace(@"%@ '%@' (%ld):\nresponse.headers=%@\nresponse.body=%@", [operation.request HTTPMethod], [[operation.request URL] absoluteString], (long)[operation.response statusCode], [operation.response allHeaderFields], operation.responseString);
} else {
RKLogInfo(@"%@ '%@' (%ld)", [operation.request HTTPMethod], [[operation.request URL] absoluteString], (long)[operation.response statusCode]);
Expand Down
2 changes: 1 addition & 1 deletion Code/Network/RKManagedObjectRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@interface RKManagedObjectRequestOperation () <RKMapperOperationDelegate>
// Core Data specific
Expand Down
2 changes: 1 addition & 1 deletion Code/Network/RKObjectParameterization.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitNetwork
#define RKLogComponent RKlcl_cRestKitNetwork

@interface RKObjectParameterization () <RKMappingOperationDelegate>
@property (nonatomic, strong) id object;
Expand Down
2 changes: 1 addition & 1 deletion Code/Network/RKObjectRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitNetwork
#define RKLogComponent RKlcl_cRestKitNetwork

static inline NSString *RKDescriptionForRequest(NSURLRequest *request)
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Network/RKResponseMapperOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitNetwork
#define RKLogComponent RKlcl_cRestKitNetwork

// Defined in RKObjectManager.h
NSURL *RKBaseURLAssociatedWithURL(NSURL *URL);
Expand Down
2 changes: 1 addition & 1 deletion Code/ObjectMapping/RKDynamicMapping.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
#define RKLogComponent RKlcl_cRestKitObjectMapping

@interface RKDynamicMapping ()
@property (nonatomic, strong) NSMutableArray *matchers;
Expand Down
2 changes: 1 addition & 1 deletion Code/ObjectMapping/RKMapperOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
#define RKLogComponent RKlcl_cRestKitObjectMapping

static NSString *RKDelegateKeyPathFromKeyPath(NSString *keyPath)
{
Expand Down
2 changes: 1 addition & 1 deletion Code/ObjectMapping/RKMappingOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
#define RKLogComponent RKlcl_cRestKitObjectMapping

// Temporary home for object equivalancy tests
BOOL RKValueIsEqualToValue(id sourceValue, id destinationValue);
Expand Down
2 changes: 1 addition & 1 deletion Code/ObjectMapping/RKPropertyInspector.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
#define RKLogComponent RKlcl_cRestKitObjectMapping

@implementation RKPropertyInspector

Expand Down
2 changes: 1 addition & 1 deletion Code/RestKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
to use RKLog() in their own app.
*/
#undef RKLogComponent
#define RKLogComponent lcl_cApp
#define RKLogComponent RKlcl_cApp
2 changes: 1 addition & 1 deletion Code/Search/RKSearchIndexer.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitSearch
#define RKLogComponent RKlcl_cRestKitSearch

NSString * const RKSearchableAttributeNamesUserInfoKey = @"RestKitSearchableAttributes";

Expand Down
2 changes: 1 addition & 1 deletion Code/Search/RKSearchWord.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// Set Logging Component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitCoreData
#define RKLogComponent RKlcl_cRestKitCoreData

@implementation RKSearchWord

Expand Down
52 changes: 26 additions & 26 deletions Code/Support/RKLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
/**
RestKit Logging is based on the LibComponentLogging framework
@see lcl_config_components.h
@see lcl_config_logger.h
@see lcl_config_components_RK.h
@see lcl_config_logger_RK.h
*/
#import "lcl.h"
#import "lcl_RK.h"

/**
RKLogComponent defines the active component within any given portion of RestKit
Expand All @@ -35,7 +35,7 @@
The component can be undef'd and redefined to change the active logging component.
*/
#define RKLogComponent lcl_cRestKit
#define RKLogComponent RKlcl_cRestKit

/**
The logging macros. These macros will log to the currently active logging component
Expand All @@ -44,10 +44,10 @@
For example, in the `RKMappingOperation` class we would redefine the RKLogComponent:
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitObjectMapping
#define RKLogComponent RKlcl_cRestKitObjectMapping
The lcl_c prefix is the LibComponentLogging data structure identifying the logging component
we want to target within this portion of the codebase. See lcl_config_component.h for reference.
The RKlcl_c prefix is the LibComponentLogging data structure identifying the logging component
we want to target within this portion of the codebase. See lcl_config_component_RK.h for reference.
Having defined the logging component, invoking the logger via:
Expand All @@ -61,35 +61,35 @@
than the level the message was logged at (in this case, Info).
*/
#define RKLogCritical(...) \
lcl_log(RKLogComponent, lcl_vCritical, @"" __VA_ARGS__)
RKlcl_log(RKLogComponent, RKlcl_vCritical, @"" __VA_ARGS__)

#define RKLogError(...) \
lcl_log(RKLogComponent, lcl_vError, @"" __VA_ARGS__)
RKlcl_log(RKLogComponent, RKlcl_vError, @"" __VA_ARGS__)

#define RKLogWarning(...) \
lcl_log(RKLogComponent, lcl_vWarning, @"" __VA_ARGS__)
RKlcl_log(RKLogComponent, RKlcl_vWarning, @"" __VA_ARGS__)

#define RKLogInfo(...) \
lcl_log(RKLogComponent, lcl_vInfo, @"" __VA_ARGS__)
RKlcl_log(RKLogComponent, RKlcl_vInfo, @"" __VA_ARGS__)

#define RKLogDebug(...) \
lcl_log(RKLogComponent, lcl_vDebug, @"" __VA_ARGS__)
RKlcl_log(RKLogComponent, RKlcl_vDebug, @"" __VA_ARGS__)

#define RKLogTrace(...) \
lcl_log(RKLogComponent, lcl_vTrace, @"" __VA_ARGS__)
RKlcl_log(RKLogComponent, RKlcl_vTrace, @"" __VA_ARGS__)

/**
Log Level Aliases
These aliases simply map the log levels defined within LibComponentLogger to something more friendly
*/
#define RKLogLevelOff lcl_vOff
#define RKLogLevelCritical lcl_vCritical
#define RKLogLevelError lcl_vError
#define RKLogLevelWarning lcl_vWarning
#define RKLogLevelInfo lcl_vInfo
#define RKLogLevelDebug lcl_vDebug
#define RKLogLevelTrace lcl_vTrace
#define RKLogLevelOff RKlcl_vOff
#define RKLogLevelCritical RKlcl_vCritical
#define RKLogLevelError RKlcl_vError
#define RKLogLevelWarning RKlcl_vWarning
#define RKLogLevelInfo RKlcl_vInfo
#define RKLogLevelDebug RKlcl_vDebug
#define RKLogLevelTrace RKlcl_vTrace

/**
Alias the LibComponentLogger logging configuration method. Also ensures logging
Expand All @@ -107,7 +107,7 @@ lcl_log(RKLogComponent, lcl_vTrace, @"" __VA_ARGS__)
*/
#define RKLogConfigureByName(name, level) \
RKLogInitialize(); \
lcl_configure_by_name(name, level);
RKlcl_configure_by_name(name, level);

/**
Alias for configuring the LibComponentLogger logging component for the App. This
Expand All @@ -116,7 +116,7 @@ lcl_configure_by_name(name, level);
*/
#define RKLogSetAppLoggingLevel(level) \
RKLogInitialize(); \
lcl_configure_by_name("App", level);
RKlcl_configure_by_name("App", level);

/**
Temporarily changes the logging level for the specified component and executes the block. Any logging
Expand All @@ -125,16 +125,16 @@ lcl_configure_by_name("App", level);
*/
#define RKLogToComponentWithLevelWhileExecutingBlock(_component, _level, _block) \
do { \
int _currentLevel = _lcl_component_level[_component]; \
lcl_configure_by_component(_component, _level); \
int _currentLevel = _RKlcl_component_level[_component]; \
RKlcl_configure_by_component(_component, _level); \
@try { \
_block(); \
} \
@catch (NSException *exception) { \
@throw; \
} \
@finally { \
lcl_configure_by_component(_component, _currentLevel); \
RKlcl_configure_by_component(_component, _currentLevel); \
} \
} while (false);

Expand Down Expand Up @@ -192,7 +192,7 @@ void RKLogInitialize(void);
Define an environment variable named RKLogLevel.RestKit.Network and set its value to "Trace"
See lcl_config_components.h for configurable RestKit logging components.
See lcl_config_components_RK.h for configurable RestKit logging components.
Valid values are the following:
Default or 0
Expand Down
6 changes: 3 additions & 3 deletions Code/Support/RKLog.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
void RKLogInitialize(void)
{
if (loggingInitialized == NO) {
lcl_configure_by_name("RestKit*", RKLogLevelDefault);
lcl_configure_by_name("App", RKLogLevelDefault);
RKlcl_configure_by_name("RestKit*", RKLogLevelDefault);
RKlcl_configure_by_name("App", RKLogLevelDefault);
RKLogInfo(@"RestKit initialized...");
loggingInitialized = YES;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ void RKLogIntegerAsBinary(NSUInteger bitMask)

void RKLogCoreDataError(NSError *error)
{
RKLogToComponentWithLevelWhileExecutingBlock(lcl_cRestKitCoreData, RKLogLevelError, ^{
RKLogToComponentWithLevelWhileExecutingBlock(RKlcl_cRestKitCoreData, RKLogLevelError, ^{
RKLogValidationError(error);
});
}
2 changes: 1 addition & 1 deletion Code/Support/RKMIMETypeSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

// Define logging component
#undef RKLogComponent
#define RKLogComponent lcl_cRestKitSupport
#define RKLogComponent RKlcl_cRestKitSupport

@interface RKMIMETypeSerializationRegistration : NSObject

Expand Down
Loading

0 comments on commit bc7c65f

Please sign in to comment.