summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-03-08 13:30:17 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-03-08 13:30:17 -0500
commiteae878256164f6912c9243cc8d2e6d06965b8181 (patch)
treeaea8cafee8c26ff819b36660e348c25f580bd534
parent51c10aa28ee538a456594e991405a0b28219eff0 (diff)
downloadsdl_ios-eae878256164f6912c9243cc8d2e6d06965b8181.tar.gz
Rename some log configuration properties
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m2
-rw-r--r--SmartDeviceLink/SDLLogConfiguration.h6
-rw-r--r--SmartDeviceLink/SDLLogConfiguration.m14
-rw-r--r--SmartDeviceLink/SDLLogManager.h6
-rw-r--r--SmartDeviceLink/SDLLogManager.m26
-rw-r--r--SmartDeviceLinkTests/LoggingSpecs/SDLLogConfigurationSpec.m16
-rw-r--r--SmartDeviceLinkTests/LoggingSpecs/SDLLogFilterSpec.m2
-rw-r--r--SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m65
8 files changed, 86 insertions, 51 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 4b28abb31..b1562d121 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -90,7 +90,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
_delegate = delegate;
// Logging
- _configuration.loggingConfig.logModules = [_configuration.loggingConfig.logModules setByAddingObjectsFromSet:[SDLLogFileModuleMap sdlModuleMap]];
+ _configuration.loggingConfig.modules = [_configuration.loggingConfig.modules setByAddingObjectsFromSet:[SDLLogFileModuleMap sdlModuleMap]];
[SDLLogManager setConfiguration:_configuration.loggingConfig];
// Private properties
diff --git a/SmartDeviceLink/SDLLogConfiguration.h b/SmartDeviceLink/SDLLogConfiguration.h
index 47e130fb6..c76a9bbfd 100644
--- a/SmartDeviceLink/SDLLogConfiguration.h
+++ b/SmartDeviceLink/SDLLogConfiguration.h
@@ -19,13 +19,13 @@ NS_ASSUME_NONNULL_BEGIN
@interface SDLLogConfiguration : NSObject <NSCopying>
// Any custom logging modules used by the developer's code. Defaults to none.
-@property (copy, nonatomic) NSSet<SDLLogFileModule *> *logModules;
+@property (copy, nonatomic) NSSet<SDLLogFileModule *> *modules;
// Where the logs will attempt to output. Defaults to Console.
-@property (copy, nonatomic) NSSet<id<SDLLogTarget>> *logTargets;
+@property (copy, nonatomic) NSSet<id<SDLLogTarget>> *targets;
// What log filters will run over this session. Defaults to none.
-@property (copy, nonatomic) NSSet<SDLLogFilterBlock> *logFilters;
+@property (copy, nonatomic) NSSet<SDLLogFilterBlock> *filters;
// How detailed of logs will be output. Defaults to Default.
@property (assign, nonatomic) SDLLogFormatType formatType;
diff --git a/SmartDeviceLink/SDLLogConfiguration.m b/SmartDeviceLink/SDLLogConfiguration.m
index 2238bba95..7d857de4d 100644
--- a/SmartDeviceLink/SDLLogConfiguration.m
+++ b/SmartDeviceLink/SDLLogConfiguration.m
@@ -20,9 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
self = [super init];
if (!self) { return nil; }
- _logModules = [NSSet set];
- _logTargets = [NSSet setWithArray:@[[SDLLogTargetASL logger]]];
- _logFilters = [NSSet set];
+ _modules = [NSSet set];
+ _targets = [NSSet setWithArray:@[[SDLLogTargetASL logger]]];
+ _filters = [NSSet set];
_formatType = SDLLogFormatTypeDefault;
_asynchronous = YES;
_errorsAsynchronous = NO;
@@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
_formatType = SDLLogFormatTypeDetailed;
_globalLogLevel = SDLLogLevelDebug;
- _logTargets = [NSSet setWithArray:@[[SDLLogTargetASL logger]]];
+ _targets = [NSSet setWithArray:@[[SDLLogTargetASL logger]]];
return self;
}
@@ -58,9 +58,9 @@ NS_ASSUME_NONNULL_BEGIN
- (id)copyWithZone:(nullable NSZone *)zone {
SDLLogConfiguration *newConfig = [[self.class allocWithZone:zone] init];
- newConfig.logModules = self.logModules;
- newConfig.logTargets = self.logTargets;
- newConfig.logFilters = self.logFilters;
+ newConfig.modules = self.modules;
+ newConfig.targets = self.targets;
+ newConfig.filters = self.filters;
newConfig.formatType = self.formatType;
newConfig.asynchronous = self.asynchronous;
newConfig.errorsAsynchronous = self.errorsAsynchronous;
diff --git a/SmartDeviceLink/SDLLogManager.h b/SmartDeviceLink/SDLLogManager.h
index c5a1b9770..9b771084b 100644
--- a/SmartDeviceLink/SDLLogManager.h
+++ b/SmartDeviceLink/SDLLogManager.h
@@ -22,9 +22,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface SDLLogManager : NSObject
-@property (copy, nonatomic, readonly) NSSet<SDLLogFileModule *> *logModules;
-@property (copy, nonatomic, readonly) NSSet<id<SDLLogTarget>> *logTargets;
-@property (copy, nonatomic, readonly) NSSet<SDLLogFilterBlock> *logFilters;
+@property (copy, nonatomic, readonly) NSSet<SDLLogFileModule *> *modules;
+@property (copy, nonatomic, readonly) NSSet<id<SDLLogTarget>> *targets;
+@property (copy, nonatomic, readonly) NSSet<SDLLogFilterBlock> *filters;
/// Any modules that do not have an explicitly specified level will by default use this log level
@property (assign, nonatomic, readonly) SDLLogLevel globalLogLevel;
diff --git a/SmartDeviceLink/SDLLogManager.m b/SmartDeviceLink/SDLLogManager.m
index 8b69fbd75..af1551d4b 100644
--- a/SmartDeviceLink/SDLLogManager.m
+++ b/SmartDeviceLink/SDLLogManager.m
@@ -17,9 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface SDLLogManager ()
-@property (copy, nonatomic, readwrite) NSSet<SDLLogFileModule *> *logModules;
-@property (copy, nonatomic, readwrite) NSSet<id<SDLLogTarget>> *logTargets;
-@property (copy, nonatomic, readwrite) NSSet<SDLLogFilterBlock> *logFilters;
+@property (copy, nonatomic, readwrite) NSSet<SDLLogFileModule *> *modules;
+@property (copy, nonatomic, readwrite) NSSet<id<SDLLogTarget>> *targets;
+@property (copy, nonatomic, readwrite) NSSet<SDLLogFilterBlock> *filters;
@property (assign, nonatomic, readwrite) SDLLogLevel globalLogLevel;
@property (assign, nonatomic, readwrite) SDLLogFormatType formatType;
@@ -53,9 +53,9 @@ static dispatch_queue_t _logQueue = NULL;
return nil;
}
- _logModules = [NSSet set];
- _logTargets = [NSSet set];
- _logFilters = [NSSet set];
+ _modules = [NSSet set];
+ _targets = [NSSet set];
+ _filters = [NSSet set];
_asynchronous = YES;
_errorsAsynchronous = NO;
@@ -81,8 +81,8 @@ static dispatch_queue_t _logQueue = NULL;
}
- (void)setConfiguration:(SDLLogConfiguration *)configuration {
- self.logModules = configuration.logModules;
- self.logFilters = configuration.logFilters;
+ self.modules = configuration.modules;
+ self.filters = configuration.filters;
self.formatType = configuration.formatType;
self.asynchronous = configuration.isAsynchronous;
self.errorsAsynchronous = configuration.areErrorsAsynchronous;
@@ -90,7 +90,7 @@ static dispatch_queue_t _logQueue = NULL;
// Start the loggers
NSMutableSet<id<SDLLogTarget>> *startedLoggers = [NSMutableSet set];
- for (id<SDLLogTarget> target in configuration.logTargets) {
+ for (id<SDLLogTarget> target in configuration.targets) {
// If the logger fails setup, discard it, otherwise, keep it
if ([target setupLogger]) {
[startedLoggers addObject:target];
@@ -99,7 +99,7 @@ static dispatch_queue_t _logQueue = NULL;
NSLog(@"(SDL) Warning: Log target failed setup: %@", NSStringFromClass(target.class));
}
}
- self.logTargets = [startedLoggers copy];
+ self.targets = [startedLoggers copy];
}
@@ -173,7 +173,7 @@ static dispatch_queue_t _logQueue = NULL;
- (void)sdl_log:(SDLLogModel *)log {
if ([self sdl_logLevelForFile:log.fileName] < log.level) { return; }
- for (SDLLogFilterBlock filter in self.logFilters) {
+ for (SDLLogFilterBlock filter in self.filters) {
if (!filter(log)) { return; }
}
@@ -190,7 +190,7 @@ static dispatch_queue_t _logQueue = NULL;
break;
}
- for (id<SDLLogTarget> target in self.logTargets) {
+ for (id<SDLLogTarget> target in self.targets) {
[target logWithLog:log formattedLog:formattedLog];
}
}
@@ -285,7 +285,7 @@ static dispatch_queue_t _logQueue = NULL;
}
- (nullable SDLLogFileModule *)sdl_moduleForFile:(NSString *)fileName {
- for (SDLLogFileModule *module in self.logModules) {
+ for (SDLLogFileModule *module in self.modules) {
if ([module containsFile:fileName]) { return module; }
}
diff --git a/SmartDeviceLinkTests/LoggingSpecs/SDLLogConfigurationSpec.m b/SmartDeviceLinkTests/LoggingSpecs/SDLLogConfigurationSpec.m
index 0eba2bf3c..880e5b780 100644
--- a/SmartDeviceLinkTests/LoggingSpecs/SDLLogConfigurationSpec.m
+++ b/SmartDeviceLinkTests/LoggingSpecs/SDLLogConfigurationSpec.m
@@ -13,10 +13,10 @@ describe(@"a log configuration", ^{
it(@"should properly set default properties", ^{
testConfiguration = [SDLLogConfiguration defaultConfiguration];
- expect(testConfiguration.logModules).to(beEmpty());
- expect(testConfiguration.logFilters).to(beEmpty());
- expect(@(testConfiguration.logTargets.count)).to(equal(@1));
- expect([testConfiguration.logTargets anyObject].class).to(equal([SDLLogTargetASL class]));
+ expect(testConfiguration.modules).to(beEmpty());
+ expect(testConfiguration.filters).to(beEmpty());
+ expect(@(testConfiguration.targets.count)).to(equal(@1));
+ expect([testConfiguration.targets anyObject].class).to(equal([SDLLogTargetASL class]));
expect(@(testConfiguration.formatType)).to(equal(@(SDLLogFormatTypeDefault)));
expect(@(testConfiguration.asynchronous)).to(equal(@YES));
expect(@(testConfiguration.errorsAsynchronous)).to(equal(@NO));
@@ -28,10 +28,10 @@ describe(@"a log configuration", ^{
it(@"should properly set debug properties", ^{
testConfiguration = [SDLLogConfiguration debugConfiguration];
- expect(testConfiguration.logModules).to(beEmpty());
- expect(testConfiguration.logFilters).to(beEmpty());
- expect(@(testConfiguration.logTargets.count)).to(equal(@1));
- expect([testConfiguration.logTargets anyObject].class).to(equal([SDLLogTargetASL class]));
+ expect(testConfiguration.modules).to(beEmpty());
+ expect(testConfiguration.filters).to(beEmpty());
+ expect(@(testConfiguration.targets.count)).to(equal(@1));
+ expect([testConfiguration.targets anyObject].class).to(equal([SDLLogTargetASL class]));
expect(@(testConfiguration.formatType)).to(equal(@(SDLLogFormatTypeDetailed)));
expect(@(testConfiguration.asynchronous)).to(equal(@YES));
expect(@(testConfiguration.errorsAsynchronous)).to(equal(@NO));
diff --git a/SmartDeviceLinkTests/LoggingSpecs/SDLLogFilterSpec.m b/SmartDeviceLinkTests/LoggingSpecs/SDLLogFilterSpec.m
index e5c659610..9e12d5e59 100644
--- a/SmartDeviceLinkTests/LoggingSpecs/SDLLogFilterSpec.m
+++ b/SmartDeviceLinkTests/LoggingSpecs/SDLLogFilterSpec.m
@@ -6,7 +6,7 @@
#import "SDLLogModel.h"
-QuickSpecBegin(SDLLogFilterSpec)
+QuickSpecBegin(SDLfilterspec)
describe(@"a filter by a string", ^{
__block NSString *testFilterString = @"filter string";
diff --git a/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m b/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m
index 361bc06fd..f8110383e 100644
--- a/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m
+++ b/SmartDeviceLinkTests/LoggingSpecs/SDLLogManagerSpec.m
@@ -11,7 +11,7 @@
QuickSpecBegin(SDLLogManagerSpec)
-describe(@"a log manager", ^{
+fdescribe(@"a log manager", ^{
__block SDLLogManager *testManager = nil;
describe(@"when initializing", ^{
@@ -19,13 +19,15 @@ describe(@"a log manager", ^{
testManager = [[SDLLogManager alloc] init];
});
- expect(testManager.logModules).toNot(beNil());
- expect(testManager.logTargets).toNot(beNil());
- expect(testManager.logFilters).toNot(beNil());
- expect(@(testManager.asynchronous)).to(beFalsy());
- expect(@(testManager.errorsAsynchronous)).to(beFalsy());
- expect(@(testManager.globalLogLevel)).to(equal(@(SDLLogLevelError)));
- expect(@(testManager.formatType)).to(equal(@(SDLLogFormatTypeDefault)));
+ it(@"should properly initialize properties", ^{
+ expect(testManager.modules).toNot(beNil());
+ expect(testManager.targets).toNot(beNil());
+ expect(testManager.filters).toNot(beNil());
+ expect(@(testManager.asynchronous)).to(beTruthy());
+ expect(@(testManager.errorsAsynchronous)).to(beFalsy());
+ expect(@(testManager.globalLogLevel)).to(equal(@(SDLLogLevelError)));
+ expect(@(testManager.formatType)).to(equal(@(SDLLogFormatTypeDefault)));
+ });
});
describe(@"after setting a configuration", ^{
@@ -37,18 +39,18 @@ describe(@"a log manager", ^{
testLogTarget = [TestLogTarget logger];
testConfiguration = [SDLLogConfiguration debugConfiguration];
- testConfiguration.logModules = [NSSet setWithObject:[SDLLogFileModule moduleWithName:@"test" files:[NSSet setWithObject:@"test"]]];
- testConfiguration.logFilters = [NSSet setWithObject:[SDLLogFilter filterByAllowingString:@"test" caseSensitive:NO]];
- testConfiguration.logTargets = [NSSet setWithObject:testLogTarget];
- testConfiguration.logTargets = [NSSet setWithObject:[TestLogTarget logger]];
+ testConfiguration.modules = [NSSet setWithObject:[SDLLogFileModule moduleWithName:@"test" files:[NSSet setWithObject:@"test"]]];
+ testConfiguration.filters = [NSSet setWithObject:[SDLLogFilter filterByAllowingString:@"test" caseSensitive:NO]];
+ testConfiguration.targets = [NSSet setWithObject:testLogTarget];
+ testConfiguration.asynchronous = NO;
[testManager setConfiguration:testConfiguration];
});
it(@"should properly set the configuration", ^{
- expect(testManager.logModules).to(equal(testConfiguration.logModules));
- expect(testManager.logFilters).to(equal(testConfiguration.logFilters));
- expect(testManager.logTargets).to(equal(testConfiguration.logTargets));
+ expect(testManager.modules).to(equal(testConfiguration.modules));
+ expect(testManager.filters).to(equal(testConfiguration.filters));
+ expect(testManager.targets).to(equal(testConfiguration.targets));
expect(@(testManager.asynchronous)).to(equal(@(testConfiguration.asynchronous)));
expect(@(testManager.errorsAsynchronous)).to(equal(@(testConfiguration.errorsAsynchronous)));
expect(@(testManager.globalLogLevel)).to(equal(@(SDLLogLevelDebug)));
@@ -66,6 +68,39 @@ describe(@"a log manager", ^{
expect(testLogTarget.loggedMessages.firstObject.message).to(equal(testMessage));
});
+
+ context(@"a simple formatted log", ^{
+ beforeEach(^{
+ testConfiguration.formatType = SDLLogFormatTypeSimple;
+ [testManager setConfiguration:testConfiguration];
+ });
+
+ it(@"should properly log the formatted message", ^{
+ expect(testLogTarget.formattedLogMessages.firstObject).to(match(@" "));
+ });
+ });
+
+ context(@"a default formatted log", ^{
+ beforeEach(^{
+ testConfiguration.formatType = SDLLogFormatTypeDefault;
+ [testManager setConfiguration:testConfiguration];
+ });
+
+ it(@"should properly log the formatted message", ^{
+ expect(testLogTarget.formattedLogMessages.firstObject).to(match(@" "));
+ });
+ });
+
+ context(@"a detailed formatted log", ^{
+ beforeEach(^{
+ testConfiguration.formatType = SDLLogFormatTypeDetailed;
+ [testManager setConfiguration:testConfiguration];
+ });
+
+ it(@"should properly log the formatted message", ^{
+ expect(testLogTarget.formattedLogMessages.firstObject).to(match(@" "));
+ });
+ });
});
});