Skip to content

Commit c22e2b7

Browse files
authored
Initial structural work for the google data logger. (#2162)
* Inital commit * Remove Example project and replace with test_spec in the podspec * Update gitignore to ignore the generated folder. * Add a script to generate the project. * Add some basic structure and tests. * Remove unnecessary files and address PR feedback. Removes .gitkeep, .gitignore, and .travis.yml files Modifies the root .gitignore to ignore files generated by cocoapod-generate Modifies the root .travis.yml to add this podspec to CI Updates the README with some instructions * Adding googledatalogger branch to travis CI * Adding copyrights to files that were missing them * Move GDLLogTransformer to the public header directory An alternative is to set CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = 'YES', but I'm not sure this will work when publishing the pod.
1 parent 87a206e commit c22e2b7

14 files changed

+325
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ Ninja
7575

7676
# Visual Studio
7777
/.vs
78+
79+
# cocoapods-generate
80+
gen/

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
before_install:
6161
- ./scripts/if_changed.sh ./scripts/install_prereqs.sh
6262
script:
63+
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh GoogleDataLogger.podspec
6364
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh GoogleUtilities.podspec
6465
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh FirebaseCore.podspec
6566
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh FirebaseAnalyticsInterop.podspec
@@ -89,6 +90,7 @@ jobs:
8990
before_install:
9091
- ./scripts/if_cron.sh ./scripts/install_prereqs.sh
9192
script:
93+
- ./scripts/if_cron.sh ./scripts/pod_lib_lint.sh GoogleDataLogger.podspec --use-libraries
9294
- ./scripts/if_cron.sh ./scripts/pod_lib_lint.sh GoogleUtilities.podspec --use-libraries
9395
- ./scripts/if_cron.sh ./scripts/pod_lib_lint.sh FirebaseCore.podspec --use-libraries
9496
- ./scripts/if_cron.sh ./scripts/pod_lib_lint.sh FirebaseAnalyticsInterop.podspec --use-libraries
@@ -178,6 +180,7 @@ jobs:
178180
before_install:
179181
- ./scripts/if_changed.sh ./scripts/install_prereqs.sh
180182
script:
183+
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh GoogleDataLogger.podspec
181184
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh GoogleUtilities.podspec
182185
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh FirebaseCore.podspec
183186
- ./scripts/if_changed.sh ./scripts/pod_lib_lint.sh FirebaseAnalyticsInterop.podspec
@@ -289,3 +292,4 @@ jobs:
289292
branches:
290293
only:
291294
- master
295+
- googledatalogger

GoogleDataLogger.podspec

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'GoogleDataLogger'
3+
s.version = '0.1.0'
4+
s.summary = 'Google Data Logging iOS SDK.'
5+
6+
7+
s.description = <<-DESC
8+
Shared library for iOS SDK data logging needs.
9+
DESC
10+
11+
s.homepage = 'https://developers.google.com/'
12+
s.license = { :type => 'Apache', :file => 'LICENSE' }
13+
s.authors = 'Google, Inc.'
14+
s.source = {
15+
:git => 'https://github.com/firebase/firebase-ios-sdk.git',
16+
:tag => 'GoogleDataLogger-' + s.version.to_s
17+
}
18+
19+
s.ios.deployment_target = '8.0'
20+
21+
s.cocoapods_version = '>= 1.5.3'
22+
23+
# TODO(mikehaney24): Change to static framework after cocoapods 1.6.0 release?
24+
s.static_framework = false
25+
s.prefix_header_file = false
26+
27+
s.source_files = 'GoogleDataLogger/GoogleDataLogger/**/*'
28+
s.public_header_files = 'GoogleDataLogger/GoogleDataLogger/Classes/Public/*.h'
29+
30+
s.pod_target_xcconfig = {
31+
'GCC_C_LANGUAGE_STANDARD' => 'c99'
32+
}
33+
34+
# Test specs
35+
s.test_spec 'Tests' do |test_spec|
36+
test_spec.source_files = 'GoogleDataLogger/Tests/**/*.{h,m}'
37+
end
38+
end

GoogleDataLogger/CHANGELOG.md

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface GDLLogEvent : NSObject
20+
21+
@end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "GDLLogEvent.h"
18+
19+
@implementation GDLLogEvent
20+
21+
@end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "GDLLogger.h"
18+
19+
@interface GDLLogger ()
20+
21+
/** The log source this logger logs to. */
22+
@property(nonatomic) NSInteger logSource;
23+
24+
/** The log transformers that will operate on logs logged by this logger. */
25+
@property(nonatomic) NSArray<id<GDLLogTransformer>> *logTransformers;
26+
27+
/** The target backend of this logger. */
28+
@property(nonatomic) NSInteger logTarget;
29+
30+
@end
31+
32+
@implementation GDLLogger
33+
34+
- (instancetype)initWithLogSource:(NSInteger)logSource
35+
logTransformers:(nullable NSArray<id<GDLLogTransformer>> *)logTransformers
36+
logTarget:(NSInteger)logTarget {
37+
self = [super init];
38+
if (self) {
39+
NSAssert(logSource > 0, @"A log source cannot be negative or 0");
40+
NSAssert(logTarget > 0, @"A log target cannot be negative or 0");
41+
_logSource = logSource;
42+
_logTransformers = logTransformers;
43+
_logTarget = logTarget;
44+
}
45+
return self;
46+
}
47+
48+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class GDLLogEvent;
20+
21+
/** Defines the API that log transformers must adopt. */
22+
@protocol GDLLogTransformer
23+
24+
/** Transforms a log by applying some logic to it. Logs returned can be nil, for example, in
25+
* instances where the log should be sampled.
26+
*
27+
* @param logEvent The log event to transform.
28+
* @return A transformed log event, or nil if the transformation removed the log event.
29+
*/
30+
- (GDLLogEvent *)transform:(GDLLogEvent *)logEvent;
31+
32+
@end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
#import "GDLLogTransformer.h"
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
@interface GDLLogger : NSObject
24+
25+
/** Please use the designated initializer. */
26+
- (instancetype)init NS_UNAVAILABLE;
27+
28+
/** Initializes a new logger that will log events to the given target backend.
29+
*
30+
* @param logSource The log source/type that this logger logs to.
31+
* @param logTransformers A list of transformers to be applied to log events that are logged.
32+
* @param logTarget The target backend of this logger.
33+
* @return A logger that will log events.
34+
*/
35+
- (instancetype)initWithLogSource:(NSInteger)logSource
36+
logTransformers:(nullable NSArray<id<GDLLogTransformer>> *)logTransformers
37+
logTarget:(NSInteger)logTarget;
38+
39+
@end
40+
41+
NS_ASSUME_NONNULL_END
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "GDLLogger.h"

GoogleDataLogger/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Google Data Logger Lib
2+
3+
This library is for internal Google use only. It allows the logging of data and
4+
telemetry from Google SDKs.
5+
6+
## Prereqs
7+
8+
- Install [cocoapod-generate](https://github.com/square/cocoapods-generate)
9+
10+
## To develop
11+
12+
- Run `generate_project.sh` after installing the prereqs
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import "GDLLogEvent.h"
20+
21+
@interface GDLLogEventTest : XCTestCase
22+
23+
@end
24+
25+
@implementation GDLLogEventTest
26+
27+
- (void)testInit {
28+
XCTAssertNotNil([[GDLLogEvent alloc] init]);
29+
}
30+
31+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2018 Google
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <XCTest/XCTest.h>
18+
19+
#import <GoogleDataLogger/GDLLogger.h>
20+
21+
@interface GDLLoggerTest : XCTestCase
22+
23+
@end
24+
25+
@implementation GDLLoggerTest
26+
27+
/** Tests the default initializer. */
28+
- (void)testInit {
29+
XCTAssertNotNil([[GDLLogger alloc] initWithLogSource:1 logTransformers:nil logTarget:1]);
30+
}
31+
32+
@end

GoogleDataLogger/generate_project.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 Google
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# From https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
19+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
20+
21+
# Remove the old generated project
22+
echo "Removing $DIR/gen"
23+
rm -rf "$DIR/gen/"
24+
25+
pod gen "$DIR/../GoogleDataLogger.podspec" --auto-open --gen-directory="$DIR/gen"

0 commit comments

Comments
 (0)