Skip to content

Commit

Permalink
Update platform versions (#55)
Browse files Browse the repository at this point in the history
* Update platform versions

* Replace new API about `FileHandle`
  • Loading branch information
sushichop authored Sep 29, 2022
1 parent b806141 commit 7d35c79
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [x.y.z](https://github.com/sushichop/Puppy/releases/tag/x.y.z) (yyyy-mm-dd)

- Disable bitcode. [#54](https://github.com/sushichop/Puppy/pull/54)
- Update platform versions. [#55](https://github.com/sushichop/Puppy/pull/55)

## [0.5.1](https://github.com/sushichop/Puppy/releases/tag/0.5.1) (2022-09-24)

Expand Down
8 changes: 4 additions & 4 deletions Configurations/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ CODE_SIGN_IDENTITY =
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO
SUPPORTS_MACCATALYST = YES

MACOSX_DEPLOYMENT_TARGET = 10.12
IPHONEOS_DEPLOYMENT_TARGET = 10.0
TVOS_DEPLOYMENT_TARGET = 10.0
WATCHOS_DEPLOYMENT_TARGET = 3.0
MACOSX_DEPLOYMENT_TARGET = 11.0
IPHONEOS_DEPLOYMENT_TARGET = 14.0
TVOS_DEPLOYMENT_TARGET = 14.0
WATCHOS_DEPLOYMENT_TARGET = 7.0

SWIFT_VERSION = 5.0

Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version": "1.4.2"
"revision": "6fe203dc33195667ce1759bf0182975e4653ba1c",
"version": "1.4.4"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import PackageDescription
let package = Package(
name: "Puppy",
platforms: [
.macOS(.v10_12), .iOS(.v10), .tvOS(.v10), .watchOS(.v3),
.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7),
],
products: [
.library(name: "Puppy", targets: ["Puppy"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.4"),
],
targets: [
.target(name: "CPuppy",
Expand Down
8 changes: 4 additions & 4 deletions Puppy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Pod::Spec.new do |s|
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Koichi Yokota" => "[email protected]" }

s.osx.deployment_target = "10.12"
s.ios.deployment_target = "10.0"
s.tvos.deployment_target = "10.0"
s.watchos.deployment_target = "3.0"
s.osx.deployment_target = "11.0"
s.ios.deployment_target = "14.0"
s.tvos.deployment_target = "14.0"
s.watchos.deployment_target = "7.0"

s.source = { :git => "https://github.com/sushichop/Puppy.git", :tag => "#{s.version}" }

Expand Down
18 changes: 9 additions & 9 deletions Puppy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
C7695BB42533303900E0CA22 /* MockLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7695BB32533303900E0CA22 /* MockLogger.swift */; };
C7695BC2253332DF00E0CA22 /* BaseLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7695BC1253332DF00E0CA22 /* BaseLoggerTests.swift */; };
C789CB8E27A81146001C7589 /* CPuppy.c in Sources */ = {isa = PBXBuildFile; fileRef = C712BB0B266F31C80016A768 /* CPuppy.c */; };
C7C3C7AF26D51D6E00856A45 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = C7C3C7AE26D51D6E00856A45 /* Logging */; };
C7AF2C2928E4AA4200B49E90 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = C7AF2C2828E4AA4200B49E90 /* Logging */; };
C7ED71A8252DBEC70065B955 /* Puppy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C7ED719E252DBEC70065B955 /* Puppy.framework */; };
C7ED71FC252DC0C50065B955 /* FileRotationLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7ED71F0252DC0C50065B955 /* FileRotationLogger.swift */; };
C7ED71FD252DC0C50065B955 /* SystemLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7ED71F1252DC0C50065B955 /* SystemLogger.swift */; };
Expand Down Expand Up @@ -140,7 +140,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C7C3C7AF26D51D6E00856A45 /* Logging in Frameworks */,
C7AF2C2928E4AA4200B49E90 /* Logging in Frameworks */,
C74F94C826778428003A88BE /* CPuppy.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -379,7 +379,7 @@
);
name = Puppy;
packageProductDependencies = (
C7C3C7AE26D51D6E00856A45 /* Logging */,
C7AF2C2828E4AA4200B49E90 /* Logging */,
);
productName = Puppy;
productReference = C7ED719E252DBEC70065B955 /* Puppy.framework */;
Expand Down Expand Up @@ -440,7 +440,7 @@
);
mainGroup = C7ED7194252DBEC70065B955;
packageReferences = (
C7C3C7AD26D51D6E00856A45 /* XCRemoteSwiftPackageReference "swift-log" */,
C7AF2C2728E4AA4200B49E90 /* XCRemoteSwiftPackageReference "swift-log" */,
);
productRefGroup = C7ED719F252DBEC70065B955 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -893,20 +893,20 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
C7C3C7AD26D51D6E00856A45 /* XCRemoteSwiftPackageReference "swift-log" */ = {
C7AF2C2728E4AA4200B49E90 /* XCRemoteSwiftPackageReference "swift-log" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-log.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.4.2;
kind = upToNextMinorVersion;
minimumVersion = 1.4.4;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
C7C3C7AE26D51D6E00856A45 /* Logging */ = {
C7AF2C2828E4AA4200B49E90 /* Logging */ = {
isa = XCSwiftPackageProductDependency;
package = C7C3C7AD26D51D6E00856A45 /* XCRemoteSwiftPackageReference "swift-log" */;
package = C7AF2C2728E4AA4200B49E90 /* XCRemoteSwiftPackageReference "swift-log" */;
productName = Logging;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
24 changes: 11 additions & 13 deletions Puppy.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"object": {
"pins": [
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version": "1.4.2"
}
"pins" : [
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
"version" : "1.4.4"
}
]
},
"version": 1
}
],
"version" : 2
}
32 changes: 7 additions & 25 deletions Sources/Puppy/FileLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public class FileLogger: BaseLogger {

public override func log(_ level: LogLevel, string: String) {
do {
_ = try fileHandle?.seekToEndCompatible()
_ = try fileHandle?.seekToEnd()
if let data = (string + "\r\n").data(using: .utf8) {
// swiftlint:disable force_try
try! fileHandle?.writeCompatible(contentsOf: data)
try! fileHandle?.write(contentsOf: data)
// swiftlint:enable force_try
if flushMode == .always {
fileHandle?.synchronizeFile()
try? fileHandle?.synchronize()
}
}
} catch {
Expand Down Expand Up @@ -70,13 +70,13 @@ public class FileLogger: BaseLogger {

public func flush() {
queue!.sync {
fileHandle?.synchronizeFile()
try? fileHandle?.synchronize()
}
}

public func flush(completion: @escaping () -> Void) {
queue!.async {
self.fileHandle?.synchronizeFile()
try? self.fileHandle?.synchronize()
completion()
}
}
Expand Down Expand Up @@ -113,8 +113,8 @@ public class FileLogger: BaseLogger {

func closeFile() {
if fileHandle != nil {
fileHandle.synchronizeFile()
fileHandle.closeFile()
try? fileHandle.synchronize()
try? fileHandle.close()
fileHandle = nil
}
}
Expand All @@ -134,21 +134,3 @@ public class FileLogger: BaseLogger {
}
}
}

extension FileHandle {
func seekToEndCompatible() throws -> UInt64 {
if #available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *) {
return try seekToEnd()
} else {
return seekToEndOfFile()
}
}

func writeCompatible(contentsOf data: Data) throws {
if #available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *) {
try write(contentsOf: data)
} else {
write(data)
}
}
}
2 changes: 1 addition & 1 deletion Sources/Puppy/FileRotationLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class FileRotationLogger: FileLogger {
}

private func rotateFiles() {
guard let size = try? fileHandle.seekToEndCompatible(), size > maxFileSize else { return }
guard let size = try? fileHandle.seekToEnd(), size > maxFileSize else { return }
closeFile()

// Rotates old archived files.
Expand Down
6 changes: 3 additions & 3 deletions Tests/PuppyTests/FileLoggerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ final class FileLoggerTests: XCTestCase {
}

func testFlushFile() throws {
let flushFileURL = URL(fileURLWithPath: "./flush.log").absoluteURL
let fileLogger = try FileLogger("com.example.yourapp.filelogger.flush", fileURL: flushFileURL, flushMode: .manual)
let fileURL = URL(fileURLWithPath: "./flush.log").absoluteURL
let fileLogger = try FileLogger("com.example.yourapp.filelogger.flush", fileURL: fileURL, flushMode: .manual)
let log = Puppy()
log.add(fileLogger)
log.trace("flush, TRACE message using FileLogger")
log.verbose("flush, VERBOSE message using FileLogger")

fileLogger.flush()
_ = fileLogger.delete(flushFileURL)
_ = fileLogger.delete(fileURL)
log.remove(fileLogger)
}

Expand Down

0 comments on commit 7d35c79

Please sign in to comment.