Skip to content

Commit 0477970

Browse files
authored
Merge pull request #15 from giginet/4.0.0-for-merge
4.0.0
2 parents bf00a6a + 8032258 commit 0477970

File tree

12 files changed

+553
-201
lines changed

12 files changed

+553
-201
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.2
1+
4.2

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
os: osx
2-
osx_image: xcode9.2
2+
osx_image: xcode10
33
language: objective-c
44
before_script:
55
- swiftlint --strict
66
- pod lib lint
77
matrix:
88
include:
99
- env: NAME=Xcode DESTINATION="platform=iOS Simulator,name=iPhone 8"
10-
- env: NAME=Xcode DESTINATION="platform=iOS Simulator,OS=9.0,name=iPhone 4s"
1110
script:
1211
- xcodebuild test -project Puree.xcodeproj -scheme PureeTests -destination "${DESTINATION}"

Puree.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |s|
22
s.name = "Puree"
3-
s.version = "3.3.0"
3+
s.version = "4.0.0"
44
s.summary = "Awesome log aggregator"
55
s.homepage = "https://github.com/cookpad/Puree-Swift"
66
s.license = { :type => "MIT", :file => "LICENSE" }
77
s.authors = { "Tomohiro Moro" => "[email protected]", "Kohki Miki" => "[email protected]", "Vincent Isambart" => "[email protected]" }
8-
s.platform = :ios, "9.0"
8+
s.platform = :ios, "10.0"
99
s.source = { :git => "https://github.com/cookpad/Puree-Swift.git", :tag => "#{s.version}" }
1010
s.source_files = "Sources/**/*.{h,swift}"
1111
end

Puree.xcodeproj/project.pbxproj

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
83E040602105E69F00B92093 /* TestingBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83E0405E2105E68C00B92093 /* TestingBuffer.swift */; };
1011
BF_104851505209 /* InMemoryLogStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_613975198094 /* InMemoryLogStore.swift */; };
1112
BF_180232540354 /* Output.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_848196260343 /* Output.swift */; };
12-
BF_198816004411 /* TestingBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_869531157922 /* TestingBuffer.swift */; };
1313
BF_210674583290 /* Filter.swift in Sources */ = {isa = PBXBuildFile; fileRef = FR_176166977065 /* Filter.swift */; };
1414
BF_219592565366 /* Puree.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FR_479946421258 /* Puree.framework */; };
1515
BF_278872148905 /* Puree.h in Headers */ = {isa = PBXBuildFile; fileRef = FR_793364177672 /* Puree.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -38,12 +38,13 @@
3838
/* End PBXContainerItemProxy section */
3939

4040
/* Begin PBXFileReference section */
41+
83E0405E2105E68C00B92093 /* TestingBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestingBuffer.swift; sourceTree = "<group>"; };
4142
FR_135157311129 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4243
FR_167045655688 /* LogEntryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogEntryTests.swift; sourceTree = "<group>"; };
4344
FR_176166977065 /* Filter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Filter.swift; sourceTree = "<group>"; };
4445
FR_254889461063 /* BufferedOutput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BufferedOutput.swift; sourceTree = "<group>"; };
4546
FR_272688927660 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
46-
FR_412093004181 /* PureeTests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = PureeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
47+
FR_412093004181 /* PureeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PureeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4748
FR_479946421258 /* Puree.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Puree.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4849
FR_613975198094 /* InMemoryLogStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InMemoryLogStore.swift; sourceTree = "<group>"; };
4950
FR_630835297098 /* BufferedOutputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BufferedOutputTests.swift; sourceTree = "<group>"; };
@@ -56,7 +57,6 @@
5657
FR_818352195712 /* LogStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogStore.swift; sourceTree = "<group>"; };
5758
FR_828954093903 /* DateProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateProvider.swift; sourceTree = "<group>"; };
5859
FR_848196260343 /* Output.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Output.swift; sourceTree = "<group>"; };
59-
FR_869531157922 /* TestingBuffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestingBuffer.swift; sourceTree = "<group>"; };
6060
FR_870064055253 /* TagPatternTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagPatternTests.swift; sourceTree = "<group>"; };
6161
FR_912035359082 /* LogEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogEntry.swift; sourceTree = "<group>"; };
6262
/* End PBXFileReference section */
@@ -73,6 +73,23 @@
7373
/* End PBXFrameworksBuildPhase section */
7474

7575
/* Begin PBXGroup section */
76+
83935AC520F88CA800FA8B9A /* Output */ = {
77+
isa = PBXGroup;
78+
children = (
79+
FR_254889461063 /* BufferedOutput.swift */,
80+
FR_848196260343 /* Output.swift */,
81+
);
82+
path = Output;
83+
sourceTree = "<group>";
84+
};
85+
83935AC620F8920500FA8B9A /* Output */ = {
86+
isa = PBXGroup;
87+
children = (
88+
FR_630835297098 /* BufferedOutputTests.swift */,
89+
);
90+
path = Output;
91+
sourceTree = "<group>";
92+
};
7693
G_1203410589804 /* LogStore */ = {
7794
isa = PBXGroup;
7895
children = (
@@ -85,11 +102,11 @@
85102
G_2671118715628 /* PureeTests */ = {
86103
isa = PBXGroup;
87104
children = (
88-
FR_630835297098 /* BufferedOutputTests.swift */,
89105
FR_135157311129 /* Info.plist */,
90106
FR_167045655688 /* LogEntryTests.swift */,
91107
FR_657386344080 /* LoggerTests.swift */,
92108
G_7185892225853 /* LogStore */,
109+
83935AC620F8920500FA8B9A /* Output */,
93110
FR_870064055253 /* TagPatternTests.swift */,
94111
G_6662760494323 /* Utilities */,
95112
);
@@ -108,13 +125,12 @@
108125
G_3400314782399 /* Puree */ = {
109126
isa = PBXGroup;
110127
children = (
111-
FR_254889461063 /* BufferedOutput.swift */,
112128
FR_176166977065 /* Filter.swift */,
113129
FR_272688927660 /* Info.plist */,
114130
FR_912035359082 /* LogEntry.swift */,
115131
FR_775709644702 /* Logger.swift */,
116132
G_1203410589804 /* LogStore */,
117-
FR_848196260343 /* Output.swift */,
133+
83935AC520F88CA800FA8B9A /* Output */,
118134
FR_793364177672 /* Puree.h */,
119135
FR_644801390644 /* TagPattern.swift */,
120136
G_3356739590045 /* Utilities */,
@@ -127,7 +143,7 @@
127143
isa = PBXGroup;
128144
children = (
129145
FR_613975198094 /* InMemoryLogStore.swift */,
130-
FR_869531157922 /* TestingBuffer.swift */,
146+
83E0405E2105E68C00B92093 /* TestingBuffer.swift */,
131147
);
132148
path = Utilities;
133149
sourceTree = "<group>";
@@ -212,6 +228,14 @@
212228
isa = PBXProject;
213229
attributes = {
214230
LastUpgradeCheck = 0940;
231+
TargetAttributes = {
232+
NT_412093004181 = {
233+
LastSwiftMigration = 1000;
234+
};
235+
NT_479946421258 = {
236+
LastSwiftMigration = 1000;
237+
};
238+
};
215239
};
216240
buildConfigurationList = CL_479946421258 /* Build configuration list for PBXProject "Puree" */;
217241
compatibilityVersion = "Xcode 3.2";
@@ -239,9 +263,9 @@
239263
BF_364947189323 /* FileLogStoreTests.swift in Sources */,
240264
BF_104851505209 /* InMemoryLogStore.swift in Sources */,
241265
BF_647931598633 /* LogEntryTests.swift in Sources */,
266+
83E040602105E69F00B92093 /* TestingBuffer.swift in Sources */,
242267
BF_859683188258 /* LoggerTests.swift in Sources */,
243268
BF_595409884047 /* TagPatternTests.swift in Sources */,
244-
BF_198816004411 /* TestingBuffer.swift in Sources */,
245269
);
246270
runOnlyForDeploymentPostprocessing = 0;
247271
};
@@ -281,6 +305,7 @@
281305
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
282306
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
283307
SDKROOT = iphoneos;
308+
SWIFT_VERSION = 4.2;
284309
TARGETED_DEVICE_FAMILY = "1,2";
285310
};
286311
name = Debug;
@@ -298,11 +323,12 @@
298323
ENABLE_TESTABILITY = YES;
299324
INFOPLIST_FILE = Sources/Puree/Info.plist;
300325
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
301-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
326+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
302327
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
303328
PRODUCT_BUNDLE_IDENTIFIER = com.cookpad.Puree;
304329
SDKROOT = iphoneos;
305330
SKIP_INSTALL = YES;
331+
SWIFT_VERSION = 4.2;
306332
TARGETED_DEVICE_FAMILY = "1,2";
307333
VERSIONING_SYSTEM = "apple-generic";
308334
};
@@ -379,11 +405,12 @@
379405
ENABLE_TESTABILITY = YES;
380406
INFOPLIST_FILE = Sources/Puree/Info.plist;
381407
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
382-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
408+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
383409
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
384410
PRODUCT_BUNDLE_IDENTIFIER = com.cookpad.Puree;
385411
SDKROOT = iphoneos;
386412
SKIP_INSTALL = YES;
413+
SWIFT_VERSION = 4.2;
387414
TARGETED_DEVICE_FAMILY = "1,2";
388415
VERSIONING_SYSTEM = "apple-generic";
389416
};
@@ -398,6 +425,7 @@
398425
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
399426
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
400427
SDKROOT = iphoneos;
428+
SWIFT_VERSION = 4.2;
401429
TARGETED_DEVICE_FAMILY = "1,2";
402430
};
403431
name = Release;

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![](Documentation/logo.png)
44

55
[![Build Status](https://travis-ci.org/cookpad/Puree-Swift.svg?branch=master)](https://travis-ci.org/cookpad/Puree-Swift)
6-
[![Language](https://img.shields.io/badge/language-Swift%204.0.2-orange.svg)](https://swift.org)
6+
[![Language](https://img.shields.io/badge/language-Swift%204.2-orange.svg)](https://swift.org)
77
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
88
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Puree.svg)](http://cocoadocs.org/docsets/Puree)
99
[![Platform](https://img.shields.io/cocoapods/p/Puree.svg?style=flat)](http://cocoadocs.org/docsets/Puree)
@@ -37,7 +37,7 @@ github "cookpad/Puree-Swift"
3737
```ruby
3838
use_frameworks!
3939

40-
pod 'Puree', '~> 3.0'
40+
pod 'Puree', '~> 4.0'
4141
```
4242

4343
## Usage

Sources/Puree/Logger.swift

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,42 @@ public final class Logger {
1919
}
2020

2121
private let configuration: Configuration
22+
private let dispatchQueue = DispatchQueue(label: "com.cookpad.Puree.Logger", qos: .background)
2223
private(set) var filters: [Filter] = []
2324
private(set) var outputs: [Output] = []
2425

2526
public var currentDate: Date {
2627
return configuration.dateProvider.now
2728
}
2829

29-
var logStore: LogStore {
30-
return configuration.logStore
31-
}
32-
3330
public init(configuration: Configuration) throws {
3431
self.configuration = configuration
3532

3633
try configuration.logStore.prepare()
3734
try configureFilterPlugins()
3835
try configureOutputPlugins()
3936

40-
outputs.forEach { $0.start() }
37+
start()
4138
}
4239

4340
private func configureFilterPlugins() throws {
4441
filters = try configuration.filterSettings.map { try $0.makeFilter() }
4542
}
4643

4744
private func configureOutputPlugins() throws {
48-
outputs = try configuration.outputSettings.map { try $0.makeOutput(logStore) }
45+
outputs = try configuration.outputSettings.map { try $0.makeOutput(configuration.logStore) }
4946
}
5047

5148
public func postLog(_ payload: [String: Any]?, tag: String) {
52-
func matchesOutputs(with tag: String) -> [Output] {
53-
return outputs.filter { $0.tagPattern.match(in: tag) != nil }
54-
}
49+
dispatchQueue.async {
50+
func matchesOutputs(with tag: String) -> [Output] {
51+
return self.outputs.filter { $0.tagPattern.match(in: tag) != nil }
52+
}
5553

56-
for log in filteredLogs(with: payload, tag: tag) {
57-
for output in matchesOutputs(with: tag) {
58-
output.emit(log: log)
54+
for log in self.filteredLogs(with: payload, tag: tag) {
55+
for output in matchesOutputs(with: tag) {
56+
output.emit(log: log)
57+
}
5958
}
6059
}
6160
}
@@ -74,18 +73,30 @@ public final class Logger {
7473
return logs
7574
}
7675

76+
private func start() {
77+
dispatchQueue.async {
78+
self.outputs.forEach { $0.start() }
79+
}
80+
}
81+
7782
public func suspend() {
78-
outputs.forEach { $0.suspend() }
83+
dispatchQueue.sync {
84+
outputs.forEach { $0.suspend() }
85+
}
7986
}
8087

8188
public func resume() {
82-
outputs.forEach { $0.resume() }
89+
dispatchQueue.async {
90+
self.outputs.forEach { $0.resume() }
91+
}
8392
}
8493

8594
public func shutdown() {
86-
filters.removeAll()
87-
suspend()
88-
outputs.removeAll()
95+
dispatchQueue.sync {
96+
filters.removeAll()
97+
outputs.forEach { $0.suspend() }
98+
outputs.removeAll()
99+
}
89100
}
90101

91102
deinit {

0 commit comments

Comments
 (0)