From 02286c1a6eab91b8349b2215e53c8715d080511f Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 18:19:44 +0100 Subject: [PATCH 01/16] Bump deployment target to 13.0 --- Logger.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index d13be27..bcdfc0c 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -374,7 +374,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -429,7 +429,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; From da03316ce6a44bc0c99738e9eb72e767455a7938 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 18:55:31 +0100 Subject: [PATCH 02/16] Remove NSFileHandle+Swift and replace it by calling __write(_:error:) --- Logger.xcodeproj/project.pbxproj | 10 ----- Logger/Logger-Bridging-Header.h | 5 --- Logger/Loggers/DiskLogger/DiskLogger.swift | 3 ++ .../Loggers/DiskLogger/NSFileHandle+Swift.h | 35 --------------- .../Loggers/DiskLogger/NSFileHandle+Swift.m | 44 ------------------- 5 files changed, 3 insertions(+), 94 deletions(-) delete mode 100644 Logger/Logger-Bridging-Header.h delete mode 100644 Logger/Loggers/DiskLogger/NSFileHandle+Swift.h delete mode 100644 Logger/Loggers/DiskLogger/NSFileHandle+Swift.m diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index bcdfc0c..46251ca 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 2EBF4B4A2122AF53008E4117 /* AgregateLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B472122AF53008E4117 /* AgregateLogger.swift */; }; 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */; }; 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B492122AF53008E4117 /* NullLogger.swift */; }; - 2EBF4B512122B06E008E4117 /* NSFileHandle+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B502122B06E008E4117 /* NSFileHandle+Swift.m */; }; 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B542122B598008E4117 /* DiskLogger.swift */; }; 2EBF4B582122B598008E4117 /* FileWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B552122B598008E4117 /* FileWriter.swift */; }; 2EBF4B592122B598008E4117 /* FileRotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B562122B598008E4117 /* FileRotate.swift */; }; @@ -58,9 +57,6 @@ 2EBF4B472122AF53008E4117 /* AgregateLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgregateLogger.swift; sourceTree = ""; }; 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsoleLogger.swift; sourceTree = ""; }; 2EBF4B492122AF53008E4117 /* NullLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NullLogger.swift; sourceTree = ""; }; - 2EBF4B4F2122B06E008E4117 /* NSFileHandle+Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSFileHandle+Swift.h"; sourceTree = ""; }; - 2EBF4B502122B06E008E4117 /* NSFileHandle+Swift.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSFileHandle+Swift.m"; sourceTree = ""; }; - 2EBF4B532122B2AA008E4117 /* Logger-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Logger-Bridging-Header.h"; sourceTree = ""; }; 2EBF4B542122B598008E4117 /* DiskLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiskLogger.swift; sourceTree = ""; }; 2EBF4B552122B598008E4117 /* FileWriter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileWriter.swift; sourceTree = ""; }; 2EBF4B562122B598008E4117 /* FileRotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileRotate.swift; sourceTree = ""; }; @@ -128,7 +124,6 @@ 2EBF4B3C2122AA34008E4117 /* Logger */ = { isa = PBXGroup; children = ( - 2EBF4B532122B2AA008E4117 /* Logger-Bridging-Header.h */, 2EBF4B442122ACD6008E4117 /* LogStringConvertible.swift */, 2EBF4B3D2122AA34008E4117 /* Logger.swift */, 2EBF4B462122AF53008E4117 /* Loggers */, @@ -153,8 +148,6 @@ 2EBF4B542122B598008E4117 /* DiskLogger.swift */, 2EBF4B552122B598008E4117 /* FileWriter.swift */, 2EBF4B562122B598008E4117 /* FileRotate.swift */, - 2EBF4B4F2122B06E008E4117 /* NSFileHandle+Swift.h */, - 2EBF4B502122B06E008E4117 /* NSFileHandle+Swift.m */, 2ED077DA2132B0320058EEFC /* FileSystem.swift */, ); path = DiskLogger; @@ -269,7 +262,6 @@ 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */, 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */, 2EBF4B3E2122AA34008E4117 /* Logger.swift in Sources */, - 2EBF4B512122B06E008E4117 /* NSFileHandle+Swift.m in Sources */, 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */, 2ED077DB2132B0320058EEFC /* FileSystem.swift in Sources */, 2EBF4B4A2122AF53008E4117 /* AgregateLogger.swift in Sources */, @@ -452,7 +444,6 @@ OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "Logger/Logger-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -472,7 +463,6 @@ OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_OBJC_BRIDGING_HEADER = "Logger/Logger-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Logger/Logger-Bridging-Header.h b/Logger/Logger-Bridging-Header.h deleted file mode 100644 index 6a5bec0..0000000 --- a/Logger/Logger-Bridging-Header.h +++ /dev/null @@ -1,5 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - -#import "Loggers/DiskLogger/NSFileHandle+Swift.h" diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index c2a44d0..340fa48 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -186,4 +186,7 @@ private class FileHandleFactory: FileFactory { extension FileHandle: File { + func swift_write(_ data: Data) throws { + try __write(data, error: ()) + } } diff --git a/Logger/Loggers/DiskLogger/NSFileHandle+Swift.h b/Logger/Loggers/DiskLogger/NSFileHandle+Swift.h deleted file mode 100644 index 23f3d4e..0000000 --- a/Logger/Loggers/DiskLogger/NSFileHandle+Swift.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// MIT License -// -// Copyright (c) 2018 Wojciech Nagrodzki -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface NSFileHandle (Swift) - -- (BOOL)swift_writeData:(NSData *)data error:(NSError **)error; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Logger/Loggers/DiskLogger/NSFileHandle+Swift.m b/Logger/Loggers/DiskLogger/NSFileHandle+Swift.m deleted file mode 100644 index 994e667..0000000 --- a/Logger/Loggers/DiskLogger/NSFileHandle+Swift.m +++ /dev/null @@ -1,44 +0,0 @@ -// -// MIT License -// -// Copyright (c) 2018 Wojciech Nagrodzki -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// - -#import "NSFileHandle+Swift.h" - -@implementation NSFileHandle (Swift) - -- (BOOL)swift_writeData:(NSData *)data error:(NSError **)error { - @try { - [self writeData:data]; - return YES; - } - @catch (NSException *exception) { - if (error == nil) { - return NO; - } - NSDictionary * userInfo = @{NSLocalizedFailureReasonErrorKey: exception.reason}; - *error = [NSError errorWithDomain:@"NSFileHandleException" code:1 userInfo:userInfo]; - return NO; - } -} - -@end From bdbd615ea420a73ceb265e678438ed8f88bfb0d7 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 19:52:06 +0100 Subject: [PATCH 03/16] Rename FileWriter to SizeLimitedFileImpl. Move SizeLimitedFile to SizeLimitedFile.swift --- Logger.xcodeproj/project.pbxproj | 16 ++++++------- Logger/Loggers/DiskLogger/DiskLogger.swift | 19 +-------------- ...FileWriter.swift => SizeLimitedFile.swift} | 23 ++++++++++++++++--- ...Tests.swift => SizeLimitedFileTests.swift} | 10 ++++---- 4 files changed, 34 insertions(+), 34 deletions(-) rename Logger/Loggers/DiskLogger/{FileWriter.swift => SizeLimitedFile.swift} (74%) rename UnitTests/{FileWriterTests.swift => SizeLimitedFileTests.swift} (86%) diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index 46251ca..1866e24 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -15,13 +15,13 @@ 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */; }; 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B492122AF53008E4117 /* NullLogger.swift */; }; 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B542122B598008E4117 /* DiskLogger.swift */; }; - 2EBF4B582122B598008E4117 /* FileWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B552122B598008E4117 /* FileWriter.swift */; }; + 2EBF4B582122B598008E4117 /* SizeLimitedFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */; }; 2EBF4B592122B598008E4117 /* FileRotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B562122B598008E4117 /* FileRotate.swift */; }; 2ED077D721329CA30058EEFC /* LoggetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D621329CA30058EEFC /* LoggetTests.swift */; }; 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */; }; 2ED077DB2132B0320058EEFC /* FileSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077DA2132B0320058EEFC /* FileSystem.swift */; }; 2ED103E12135C61100EB3683 /* FileRotateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E02135C61100EB3683 /* FileRotateTests.swift */; }; - 2ED103E32135D3FB00EB3683 /* FileWriterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E22135D3FB00EB3683 /* FileWriterTests.swift */; }; + 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */; }; 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */; }; /* End PBXBuildFile section */ @@ -58,13 +58,13 @@ 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsoleLogger.swift; sourceTree = ""; }; 2EBF4B492122AF53008E4117 /* NullLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NullLogger.swift; sourceTree = ""; }; 2EBF4B542122B598008E4117 /* DiskLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiskLogger.swift; sourceTree = ""; }; - 2EBF4B552122B598008E4117 /* FileWriter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileWriter.swift; sourceTree = ""; }; + 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SizeLimitedFile.swift; sourceTree = ""; }; 2EBF4B562122B598008E4117 /* FileRotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileRotate.swift; sourceTree = ""; }; 2ED077D621329CA30058EEFC /* LoggetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggetTests.swift; sourceTree = ""; }; 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgregateLoggerTests.swift; sourceTree = ""; }; 2ED077DA2132B0320058EEFC /* FileSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSystem.swift; sourceTree = ""; }; 2ED103E02135C61100EB3683 /* FileRotateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileRotateTests.swift; sourceTree = ""; }; - 2ED103E22135D3FB00EB3683 /* FileWriterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileWriterTests.swift; sourceTree = ""; }; + 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeLimitedFileTests.swift; sourceTree = ""; }; 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskLoggerTests.swift; sourceTree = ""; }; 2EDA8AE8213ACCFF00FE5840 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; /* End PBXFileReference section */ @@ -95,7 +95,7 @@ 2ED077D621329CA30058EEFC /* LoggetTests.swift */, 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */, 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */, - 2ED103E22135D3FB00EB3683 /* FileWriterTests.swift */, + 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */, 2ED103E02135C61100EB3683 /* FileRotateTests.swift */, 2E58D35E21316C3500BEF81A /* Info.plist */, ); @@ -146,7 +146,7 @@ isa = PBXGroup; children = ( 2EBF4B542122B598008E4117 /* DiskLogger.swift */, - 2EBF4B552122B598008E4117 /* FileWriter.swift */, + 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */, 2EBF4B562122B598008E4117 /* FileRotate.swift */, 2ED077DA2132B0320058EEFC /* FileSystem.swift */, ); @@ -246,7 +246,7 @@ buildActionMask = 2147483647; files = ( 2E58D35D21316C3500BEF81A /* LogStringConvertibleTests.swift in Sources */, - 2ED103E32135D3FB00EB3683 /* FileWriterTests.swift in Sources */, + 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */, 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */, 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */, 2ED103E12135C61100EB3683 /* FileRotateTests.swift in Sources */, @@ -258,7 +258,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2EBF4B582122B598008E4117 /* FileWriter.swift in Sources */, + 2EBF4B582122B598008E4117 /* SizeLimitedFile.swift in Sources */, 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */, 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */, 2EBF4B3E2122AA34008E4117 /* Logger.swift in Sources */, diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index 340fa48..a6952de 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -24,23 +24,6 @@ import Foundation -/// Write failed as allowed size limit would be exceeded. -public struct SizeLimitedFileQuotaReached: Error {} - -/// Allows writing to a file while respecting allowed size limit. -protocol SizeLimitedFile { - - /// Synchronously writes `data` at the end of the file. - /// - /// - Parameter data: The data to be written. - /// - Throws: Throws an error if no free space is left on the file system, or if any other writing error occurs. - /// Throws `SizeLimitedFileQuotaReached` if allowed size limit would be exceeded. - func write(_ data: Data) throws - - /// Writes all in-memory data to permanent storage and closes the file. - func synchronizeAndCloseFile() -} - protocol SizeLimitedFileFactory { /// Returns newly initialized SizeLimitedFile instance. @@ -174,7 +157,7 @@ private class FileRotateFactory: LogrotateFactory { private class FileWriterFactory: SizeLimitedFileFactory { func makeInstance(fileURL: URL, fileSizeLimit: UInt64) throws -> SizeLimitedFile { - return try FileWriter(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactory()) + return try SizeLimitedFileImpl(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactory()) } } diff --git a/Logger/Loggers/DiskLogger/FileWriter.swift b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift similarity index 74% rename from Logger/Loggers/DiskLogger/FileWriter.swift rename to Logger/Loggers/DiskLogger/SizeLimitedFile.swift index be1ff30..29fc221 100644 --- a/Logger/Loggers/DiskLogger/FileWriter.swift +++ b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift @@ -35,14 +35,31 @@ protocol FileFactory { func makeInstance(forWritingTo: URL) throws -> File } +/// Write failed as allowed size limit would be exceeded. +public struct SizeLimitedFileQuotaReached: Error {} + /// Allows writing to a file while respecting allowed size limit. -final class FileWriter { +protocol SizeLimitedFile { + + /// Synchronously writes `data` at the end of the file. + /// + /// - Parameter data: The data to be written. + /// - Throws: Throws an error if no free space is left on the file system, or if any other writing error occurs. + /// Throws `SizeLimitedFileQuotaReached` if allowed size limit would be exceeded. + func write(_ data: Data) throws + + /// Writes all in-memory data to permanent storage and closes the file. + func synchronizeAndCloseFile() +} + +/// Allows writing to a file while respecting allowed size limit. +final class SizeLimitedFileImpl { private let file: File private let sizeLimit: UInt64 private var currentSize: UInt64 - /// Initializes new FileWriter instance. + /// Initializes new SizeLimitedFileImpl instance. /// /// - Parameters: /// - fileURL: URL of the file. @@ -55,7 +72,7 @@ final class FileWriter { } } -extension FileWriter: SizeLimitedFile { +extension SizeLimitedFileImpl: SizeLimitedFile { func write(_ data: Data) throws { let dataSize = UInt64(data.count) diff --git a/UnitTests/FileWriterTests.swift b/UnitTests/SizeLimitedFileTests.swift similarity index 86% rename from UnitTests/FileWriterTests.swift rename to UnitTests/SizeLimitedFileTests.swift index 222991c..c6e7987 100644 --- a/UnitTests/FileWriterTests.swift +++ b/UnitTests/SizeLimitedFileTests.swift @@ -25,20 +25,20 @@ import XCTest @testable import Logger -class FileWriterTests: XCTestCase { +class SizeLimitedFileTests: XCTestCase { let logURL = URL(fileURLWithPath: "/var/log/application.log") func testFileOpeningFailure() { let factory = UnopenableFileFactory() - XCTAssertThrowsError(try FileWriter(fileURL: logURL, fileSizeLimit: 0, fileFactory: factory), "file open failure") { (error) in + XCTAssertThrowsError(try SizeLimitedFileImpl(fileURL: logURL, fileSizeLimit: 0, fileFactory: factory), "file open failure") { (error) in XCTAssertTrue(error is UnopenableFileFactory.OpenFileError) } } func testKeepingFileSizeLimit() throws { let factory = FileMockFactory() - let writer = try FileWriter(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) + let writer = try SizeLimitedFileImpl(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) let data = Data([0]) try writer.write(data) @@ -47,7 +47,7 @@ class FileWriterTests: XCTestCase { func testExceedingFileSizeLimit() throws { let factory = FileMockFactory() - let writer = try FileWriter(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) + let writer = try SizeLimitedFileImpl(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) let data = Data([0, 0]) XCTAssertThrowsError(try writer.write(data), "file size limit exceeded") { (error) in @@ -59,7 +59,7 @@ class FileWriterTests: XCTestCase { func testSynchronizingAndClosingFile() throws { let factory = FileMockFactory() - let writer = try FileWriter(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) + let writer = try SizeLimitedFileImpl(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) writer.synchronizeAndCloseFile() XCTAssertTrue(factory.mock.synchronizeFileCallCount == 1 && factory.mock.closeFileCallCount == 1) } From 81393b67dae30e786a8746765a8dc574fd5078aa Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 20:02:45 +0100 Subject: [PATCH 04/16] Rename FileRotate to LogrotateImpl. Move Logrotate to Logrotate.swift --- Logger.xcodeproj/project.pbxproj | 16 +++++++------- Logger/Loggers/DiskLogger/DiskLogger.swift | 16 +------------- .../{Filerotate.swift => Logrotate.swift} | 18 +++++++++++++-- ...RotateTests.swift => LogrotateTests.swift} | 22 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) rename Logger/Loggers/DiskLogger/{Filerotate.swift => Logrotate.swift} (83%) rename UnitTests/{FileRotateTests.swift => LogrotateTests.swift} (84%) diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index 1866e24..387575a 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -16,11 +16,11 @@ 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B492122AF53008E4117 /* NullLogger.swift */; }; 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B542122B598008E4117 /* DiskLogger.swift */; }; 2EBF4B582122B598008E4117 /* SizeLimitedFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */; }; - 2EBF4B592122B598008E4117 /* FileRotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B562122B598008E4117 /* FileRotate.swift */; }; + 2EBF4B592122B598008E4117 /* Logrotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B562122B598008E4117 /* Logrotate.swift */; }; 2ED077D721329CA30058EEFC /* LoggetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D621329CA30058EEFC /* LoggetTests.swift */; }; 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */; }; 2ED077DB2132B0320058EEFC /* FileSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077DA2132B0320058EEFC /* FileSystem.swift */; }; - 2ED103E12135C61100EB3683 /* FileRotateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E02135C61100EB3683 /* FileRotateTests.swift */; }; + 2ED103E12135C61100EB3683 /* LogrotateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E02135C61100EB3683 /* LogrotateTests.swift */; }; 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */; }; 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */; }; /* End PBXBuildFile section */ @@ -59,11 +59,11 @@ 2EBF4B492122AF53008E4117 /* NullLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NullLogger.swift; sourceTree = ""; }; 2EBF4B542122B598008E4117 /* DiskLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiskLogger.swift; sourceTree = ""; }; 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SizeLimitedFile.swift; sourceTree = ""; }; - 2EBF4B562122B598008E4117 /* FileRotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileRotate.swift; sourceTree = ""; }; + 2EBF4B562122B598008E4117 /* Logrotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logrotate.swift; sourceTree = ""; }; 2ED077D621329CA30058EEFC /* LoggetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggetTests.swift; sourceTree = ""; }; 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgregateLoggerTests.swift; sourceTree = ""; }; 2ED077DA2132B0320058EEFC /* FileSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSystem.swift; sourceTree = ""; }; - 2ED103E02135C61100EB3683 /* FileRotateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileRotateTests.swift; sourceTree = ""; }; + 2ED103E02135C61100EB3683 /* LogrotateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogrotateTests.swift; sourceTree = ""; }; 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeLimitedFileTests.swift; sourceTree = ""; }; 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskLoggerTests.swift; sourceTree = ""; }; 2EDA8AE8213ACCFF00FE5840 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -96,7 +96,7 @@ 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */, 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */, 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */, - 2ED103E02135C61100EB3683 /* FileRotateTests.swift */, + 2ED103E02135C61100EB3683 /* LogrotateTests.swift */, 2E58D35E21316C3500BEF81A /* Info.plist */, ); path = UnitTests; @@ -147,7 +147,7 @@ children = ( 2EBF4B542122B598008E4117 /* DiskLogger.swift */, 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */, - 2EBF4B562122B598008E4117 /* FileRotate.swift */, + 2EBF4B562122B598008E4117 /* Logrotate.swift */, 2ED077DA2132B0320058EEFC /* FileSystem.swift */, ); path = DiskLogger; @@ -249,7 +249,7 @@ 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */, 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */, 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */, - 2ED103E12135C61100EB3683 /* FileRotateTests.swift in Sources */, + 2ED103E12135C61100EB3683 /* LogrotateTests.swift in Sources */, 2ED077D721329CA30058EEFC /* LoggetTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -265,7 +265,7 @@ 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */, 2ED077DB2132B0320058EEFC /* FileSystem.swift in Sources */, 2EBF4B4A2122AF53008E4117 /* AgregateLogger.swift in Sources */, - 2EBF4B592122B598008E4117 /* FileRotate.swift in Sources */, + 2EBF4B592122B598008E4117 /* Logrotate.swift in Sources */, 2EBF4B452122ACD6008E4117 /* LogStringConvertible.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index a6952de..df97e21 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -35,20 +35,6 @@ protocol SizeLimitedFileFactory { func makeInstance(fileURL: URL, fileSizeLimit: UInt64) throws -> SizeLimitedFile } -/// Allows log files rotation. -protocol Logrotate { - - /// Rotates log files `rotations` number of times. - /// - /// First deletes file at `.`. - /// Next moves files located at: - /// - /// `, .1, .2 ... .` - /// - /// to `.1, .2 ... .` - func rotate() throws -} - protocol LogrotateFactory { /// Returns newly initialized Logrotate instance. @@ -151,7 +137,7 @@ public final class DiskLogger: Logger { private class FileRotateFactory: LogrotateFactory { func makeInstance(fileURL: URL, rotations: Int) -> Logrotate { - return FileRotate(fileURL: fileURL, rotations: rotations, fileSystem: FileManager.default) + return LogrotateImpl(fileURL: fileURL, rotations: rotations, fileSystem: FileManager.default) } } diff --git a/Logger/Loggers/DiskLogger/Filerotate.swift b/Logger/Loggers/DiskLogger/Logrotate.swift similarity index 83% rename from Logger/Loggers/DiskLogger/Filerotate.swift rename to Logger/Loggers/DiskLogger/Logrotate.swift index 0963cfa..93d4e84 100644 --- a/Logger/Loggers/DiskLogger/Filerotate.swift +++ b/Logger/Loggers/DiskLogger/Logrotate.swift @@ -24,7 +24,21 @@ import Foundation -final class FileRotate { +/// Allows log files rotation. +protocol Logrotate { + + /// Rotates log files `rotations` number of times. + /// + /// First deletes file at `.`. + /// Next moves files located at: + /// + /// `, .1, .2 ... .` + /// + /// to `.1, .2 ... .` + func rotate() throws +} + +final class LogrotateImpl { private let fileURL: URL private let rotations: Int @@ -43,7 +57,7 @@ final class FileRotate { } } -extension FileRotate: Logrotate { +extension LogrotateImpl: Logrotate { func rotate() throws { let range = 1...rotations diff --git a/UnitTests/FileRotateTests.swift b/UnitTests/LogrotateTests.swift similarity index 84% rename from UnitTests/FileRotateTests.swift rename to UnitTests/LogrotateTests.swift index 13ca7c0..f5f576c 100644 --- a/UnitTests/FileRotateTests.swift +++ b/UnitTests/LogrotateTests.swift @@ -25,7 +25,7 @@ import XCTest @testable import Logger -class FileRotateTests: XCTestCase { +class LogrotateTests: XCTestCase { let logURL = URL(fileURLWithPath: "/var/log/application.log") let log1URL = URL(fileURLWithPath: "/var/log/application.log.1") @@ -34,7 +34,7 @@ class FileRotateTests: XCTestCase { func test_1rotation_0files() { let fileSystem = FileSystemMock(files: []) - let logrotate = FileRotate(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -44,7 +44,7 @@ class FileRotateTests: XCTestCase { func test_1rotation_1file() { let fileSystem = FileSystemMock(files: [logURL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -54,7 +54,7 @@ class FileRotateTests: XCTestCase { func test_1rotation_2files() { let fileSystem = FileSystemMock(files: [logURL, log1URL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -64,7 +64,7 @@ class FileRotateTests: XCTestCase { func test_1rotation_3files() { let fileSystem = FileSystemMock(files: [logURL, log1URL, log2URL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -74,7 +74,7 @@ class FileRotateTests: XCTestCase { func test_2rotations_0files() { let fileSystem = FileSystemMock(files: []) - let logrotate = FileRotate(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -84,7 +84,7 @@ class FileRotateTests: XCTestCase { func test_2rotations_1file() { let fileSystem = FileSystemMock(files: [logURL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -94,7 +94,7 @@ class FileRotateTests: XCTestCase { func test_2rotations_2files() { let fileSystem = FileSystemMock(files: [logURL, log1URL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -104,7 +104,7 @@ class FileRotateTests: XCTestCase { func test_2rotations_3files() { let fileSystem = FileSystemMock(files: [logURL, log1URL, log2URL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -114,7 +114,7 @@ class FileRotateTests: XCTestCase { func test_2rotations_4files() { let fileSystem = FileSystemMock(files: [logURL, log1URL, log2URL, log3URL]) - let logrotate = FileRotate(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) try? logrotate.rotate() let actual = fileSystem.files @@ -124,7 +124,7 @@ class FileRotateTests: XCTestCase { func testErrorPropagation() { let fileSystem = BrokenFileSystem() - let logrotate = FileRotate(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) XCTAssertThrowsError(try logrotate.rotate(), "An error when removing or moving an item") { (error) in XCTAssertTrue(error is BrokenFileSystem.IOError) From 1eb496f343615fce2bc70af144960847a1348917 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 20:05:14 +0100 Subject: [PATCH 05/16] Rename FileSystem to OSFileManager --- Logger.xcodeproj/project.pbxproj | 8 +-- Logger/Loggers/DiskLogger/DiskLogger.swift | 14 ++--- Logger/Loggers/DiskLogger/Logrotate.swift | 14 ++--- .../{FileSystem.swift => OSFileManager.swift} | 4 +- UnitTests/DiskLoggerTests.swift | 14 ++--- UnitTests/LogrotateTests.swift | 62 +++++++++---------- 6 files changed, 58 insertions(+), 58 deletions(-) rename Logger/Loggers/DiskLogger/{FileSystem.swift => OSFileManager.swift} (95%) diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index 387575a..8376b6e 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -19,7 +19,7 @@ 2EBF4B592122B598008E4117 /* Logrotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B562122B598008E4117 /* Logrotate.swift */; }; 2ED077D721329CA30058EEFC /* LoggetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D621329CA30058EEFC /* LoggetTests.swift */; }; 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */; }; - 2ED077DB2132B0320058EEFC /* FileSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077DA2132B0320058EEFC /* FileSystem.swift */; }; + 2ED077DB2132B0320058EEFC /* OSFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077DA2132B0320058EEFC /* OSFileManager.swift */; }; 2ED103E12135C61100EB3683 /* LogrotateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E02135C61100EB3683 /* LogrotateTests.swift */; }; 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */; }; 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */; }; @@ -62,7 +62,7 @@ 2EBF4B562122B598008E4117 /* Logrotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logrotate.swift; sourceTree = ""; }; 2ED077D621329CA30058EEFC /* LoggetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggetTests.swift; sourceTree = ""; }; 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgregateLoggerTests.swift; sourceTree = ""; }; - 2ED077DA2132B0320058EEFC /* FileSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSystem.swift; sourceTree = ""; }; + 2ED077DA2132B0320058EEFC /* OSFileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSFileManager.swift; sourceTree = ""; }; 2ED103E02135C61100EB3683 /* LogrotateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogrotateTests.swift; sourceTree = ""; }; 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeLimitedFileTests.swift; sourceTree = ""; }; 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskLoggerTests.swift; sourceTree = ""; }; @@ -148,7 +148,7 @@ 2EBF4B542122B598008E4117 /* DiskLogger.swift */, 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */, 2EBF4B562122B598008E4117 /* Logrotate.swift */, - 2ED077DA2132B0320058EEFC /* FileSystem.swift */, + 2ED077DA2132B0320058EEFC /* OSFileManager.swift */, ); path = DiskLogger; sourceTree = ""; @@ -263,7 +263,7 @@ 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */, 2EBF4B3E2122AA34008E4117 /* Logger.swift in Sources */, 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */, - 2ED077DB2132B0320058EEFC /* FileSystem.swift in Sources */, + 2ED077DB2132B0320058EEFC /* OSFileManager.swift in Sources */, 2EBF4B4A2122AF53008E4117 /* AgregateLogger.swift in Sources */, 2EBF4B592122B598008E4117 /* Logrotate.swift in Sources */, 2EBF4B452122ACD6008E4117 /* LogStringConvertible.swift in Sources */, diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index df97e21..3ffc4e2 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -51,7 +51,7 @@ public final class DiskLogger: Logger { private let fileURL: URL private let fileSizeLimit: UInt64 private let rotations: Int - private let fileSystem: FileSystem + private let fileManager: OSFileManager private let sizeLimitedFileFactory: SizeLimitedFileFactory private let logrotateFactory: LogrotateFactory private let formatter: DateFormatter @@ -66,14 +66,14 @@ public final class DiskLogger: Logger { /// - fileSizeLimit: Maximum size log file can reach in bytes. Attempt to exceeding that limit triggers log files rotation. /// - rotations: Number of times log files are rotated before being removed. public convenience init(fileURL: URL, fileSizeLimit: UInt64, rotations: Int) { - self.init(fileURL: fileURL, fileSizeLimit: fileSizeLimit, rotations: rotations, fileSystem: FileManager.default, sizeLimitedFileFactory: FileWriterFactory(), logrotateFactory: FileRotateFactory()) + self.init(fileURL: fileURL, fileSizeLimit: fileSizeLimit, rotations: rotations, fileManager: FileManager.default, sizeLimitedFileFactory: FileWriterFactory(), logrotateFactory: FileRotateFactory()) } - init(fileURL: URL, fileSizeLimit: UInt64, rotations: Int, fileSystem: FileSystem, sizeLimitedFileFactory: SizeLimitedFileFactory, logrotateFactory: LogrotateFactory) { + init(fileURL: URL, fileSizeLimit: UInt64, rotations: Int, fileManager: OSFileManager, sizeLimitedFileFactory: SizeLimitedFileFactory, logrotateFactory: LogrotateFactory) { self.fileURL = fileURL self.fileSizeLimit = fileSizeLimit self.rotations = rotations - self.fileSystem = fileSystem + self.fileManager = fileManager self.sizeLimitedFileFactory = sizeLimitedFileFactory self.logrotateFactory = logrotateFactory formatter = DateFormatter() @@ -113,8 +113,8 @@ public final class DiskLogger: Logger { private func openSizeLimitedFile() throws { guard sizeLimitedFile == nil else { return } - if fileSystem.itemExists(at: fileURL) == false { - _ = fileSystem.createFile(at: fileURL) + if fileManager.itemExists(at: fileURL) == false { + _ = fileManager.createFile(at: fileURL) } sizeLimitedFile = try sizeLimitedFileFactory.makeInstance(fileURL: fileURL, fileSizeLimit: fileSizeLimit) } @@ -137,7 +137,7 @@ public final class DiskLogger: Logger { private class FileRotateFactory: LogrotateFactory { func makeInstance(fileURL: URL, rotations: Int) -> Logrotate { - return LogrotateImpl(fileURL: fileURL, rotations: rotations, fileSystem: FileManager.default) + return LogrotateImpl(fileURL: fileURL, rotations: rotations, fileManager: FileManager.default) } } diff --git a/Logger/Loggers/DiskLogger/Logrotate.swift b/Logger/Loggers/DiskLogger/Logrotate.swift index 93d4e84..4d640c7 100644 --- a/Logger/Loggers/DiskLogger/Logrotate.swift +++ b/Logger/Loggers/DiskLogger/Logrotate.swift @@ -42,18 +42,18 @@ final class LogrotateImpl { private let fileURL: URL private let rotations: Int - private let fileSystem: FileSystem + private let fileManager: OSFileManager /// Initializes new Logrotate instance. /// /// - Parameters: /// - fileURL: URL of the log file. /// - rotations: Number of times log files are rotated before being removed. - init(fileURL: URL, rotations: Int, fileSystem: FileSystem) { + init(fileURL: URL, rotations: Int, fileManager: OSFileManager) { precondition(rotations > 0) self.fileURL = fileURL self.rotations = rotations - self.fileSystem = fileSystem + self.fileManager = fileManager } } @@ -68,12 +68,12 @@ extension LogrotateImpl: Logrotate { let toDelete = rotatedURLs.last! let toMove = zip(allURLs, rotatedURLs).reversed() - if fileSystem.itemExists(at: toDelete) { - try fileSystem.removeItem(at: toDelete) + if fileManager.itemExists(at: toDelete) { + try fileManager.removeItem(at: toDelete) } for (oldURL, newURL) in toMove { - guard fileSystem.itemExists(at: oldURL) else { continue } - try fileSystem.moveItem(at: oldURL, to: newURL) + guard fileManager.itemExists(at: oldURL) else { continue } + try fileManager.moveItem(at: oldURL, to: newURL) } } } diff --git a/Logger/Loggers/DiskLogger/FileSystem.swift b/Logger/Loggers/DiskLogger/OSFileManager.swift similarity index 95% rename from Logger/Loggers/DiskLogger/FileSystem.swift rename to Logger/Loggers/DiskLogger/OSFileManager.swift index b47b316..02ae5be 100644 --- a/Logger/Loggers/DiskLogger/FileSystem.swift +++ b/Logger/Loggers/DiskLogger/OSFileManager.swift @@ -24,14 +24,14 @@ import Foundation -public protocol FileSystem { +public protocol OSFileManager { func itemExists(at URL: URL) -> Bool func removeItem(at URL: URL) throws func moveItem(at srcURL: URL, to dstURL: URL) throws func createFile(at URL: URL) -> Bool } -extension FileManager: FileSystem { +extension FileManager: OSFileManager { public func itemExists(at URL: URL) -> Bool { return fileExists(atPath: URL.path) diff --git a/UnitTests/DiskLoggerTests.swift b/UnitTests/DiskLoggerTests.swift index aaededc..4a08210 100644 --- a/UnitTests/DiskLoggerTests.swift +++ b/UnitTests/DiskLoggerTests.swift @@ -33,13 +33,13 @@ class DiskLoggerTests: XCTestCase { let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") expectation.expectedFulfillmentCount = 1 - let filesystem = FileSystemStub() + let fimeManager = FileManagerStub() let sizeLimitedFileFactory = SizeLimitedFileMockFactory(writeCall: expectation) let logrotateFactory = LogrotateMockFactory() let logger = DiskLogger(fileURL: logURL, fileSizeLimit: 1024, rotations: 1, - fileSystem: filesystem, + fileManager: fimeManager, sizeLimitedFileFactory: sizeLimitedFileFactory, logrotateFactory: logrotateFactory) @@ -61,13 +61,13 @@ class DiskLoggerTests: XCTestCase { let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") expectation.expectedFulfillmentCount = 2 - let filesystem = FileSystemStub() + let fimeManager = FileManagerStub() let sizeLimitedFileFactory = SizeLimitedFileMockFactory(writeCall: expectation) let logrotateFactory = LogrotateMockFactory() let logger = DiskLogger(fileURL: logURL, fileSizeLimit: 91, rotations: 1, - fileSystem: filesystem, + fileManager: fimeManager, sizeLimitedFileFactory: sizeLimitedFileFactory, logrotateFactory: logrotateFactory) @@ -90,13 +90,13 @@ class DiskLoggerTests: XCTestCase { let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") expectation.expectedFulfillmentCount = 2 - let filesystem = FileSystemStub() + let fimeManager = FileManagerStub() let sizeLimitedFileFactory = UnwritableFileStubFactory(writeCall: expectation) let logrotateFactory = LogrotateMockFactory() let logger = DiskLogger(fileURL: logURL, fileSizeLimit: 91, rotations: 1, - fileSystem: filesystem, + fileManager: fimeManager, sizeLimitedFileFactory: sizeLimitedFileFactory, logrotateFactory: logrotateFactory) @@ -116,7 +116,7 @@ class DiskLoggerTests: XCTestCase { } } -private class FileSystemStub: FileSystem { +private class FileManagerStub: OSFileManager { func itemExists(at URL: URL) -> Bool { return false } diff --git a/UnitTests/LogrotateTests.swift b/UnitTests/LogrotateTests.swift index f5f576c..0aa968b 100644 --- a/UnitTests/LogrotateTests.swift +++ b/UnitTests/LogrotateTests.swift @@ -33,98 +33,98 @@ class LogrotateTests: XCTestCase { let log3URL = URL(fileURLWithPath: "/var/log/application.log.3") func test_1rotation_0files() { - let fileSystem = FileSystemMock(files: []) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: []) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set() XCTAssertEqual(actual, expected) } func test_1rotation_1file() { - let fileSystem = FileSystemMock(files: [logURL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL]) XCTAssertEqual(actual, expected) } func test_1rotation_2files() { - let fileSystem = FileSystemMock(files: [logURL, log1URL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL, log1URL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL]) XCTAssertEqual(actual, expected) } func test_1rotation_3files() { - let fileSystem = FileSystemMock(files: [logURL, log1URL, log2URL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL, log1URL, log2URL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL, log2URL]) XCTAssertEqual(actual, expected) } func test_2rotations_0files() { - let fileSystem = FileSystemMock(files: []) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: []) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set() XCTAssertEqual(actual, expected) } func test_2rotations_1file() { - let fileSystem = FileSystemMock(files: [logURL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL]) XCTAssertEqual(actual, expected) } func test_2rotations_2files() { - let fileSystem = FileSystemMock(files: [logURL, log1URL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL, log1URL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL, log2URL]) XCTAssertEqual(actual, expected) } func test_2rotations_3files() { - let fileSystem = FileSystemMock(files: [logURL, log1URL, log2URL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL, log1URL, log2URL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL, log2URL]) XCTAssertEqual(actual, expected) } func test_2rotations_4files() { - let fileSystem = FileSystemMock(files: [logURL, log1URL, log2URL, log3URL]) - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileSystem: fileSystem) + let fimeManager = FileManagerMock(files: [logURL, log1URL, log2URL, log3URL]) + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 2, fileManager: fimeManager) try? logrotate.rotate() - let actual = fileSystem.files + let actual = fimeManager.files let expected = Set([log1URL, log2URL, log3URL]) XCTAssertEqual(actual, expected) } func testErrorPropagation() { - let fileSystem = BrokenFileSystem() - let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileSystem: fileSystem) + let fimeManager = BrokenFileSystem() + let logrotate = LogrotateImpl(fileURL: logURL, rotations: 1, fileManager: fimeManager) XCTAssertThrowsError(try logrotate.rotate(), "An error when removing or moving an item") { (error) in XCTAssertTrue(error is BrokenFileSystem.IOError) @@ -132,7 +132,7 @@ class LogrotateTests: XCTestCase { } } -private class FileSystemMock: FileSystem { +private class FileManagerMock: OSFileManager { private(set) var files = Set() @@ -159,7 +159,7 @@ private class FileSystemMock: FileSystem { } } -private class BrokenFileSystem: FileSystem { +private class BrokenFileSystem: OSFileManager { struct IOError: Error { } From 3f90ca9fa680132bec15990d56a5390ec3bf5f0c Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 20:24:02 +0100 Subject: [PATCH 06/16] Rename File to OSFileHandle. Move OSFileHandle to OSFileHandle.swift --- Logger.xcodeproj/project.pbxproj | 4 ++++ Logger/Loggers/DiskLogger/DiskLogger.swift | 9 +------- Logger/Loggers/DiskLogger/OSFileHandle.swift | 23 +++++++++++++++++++ .../Loggers/DiskLogger/SizeLimitedFile.swift | 11 ++------- UnitTests/SizeLimitedFileTests.swift | 6 ++--- 5 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 Logger/Loggers/DiskLogger/OSFileHandle.swift diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index 8376b6e..317817a 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 2ED103E12135C61100EB3683 /* LogrotateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E02135C61100EB3683 /* LogrotateTests.swift */; }; 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */; }; 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */; }; + 2ED83781236A19A60008C01F /* OSFileHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED83780236A19A60008C01F /* OSFileHandle.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -66,6 +67,7 @@ 2ED103E02135C61100EB3683 /* LogrotateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogrotateTests.swift; sourceTree = ""; }; 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeLimitedFileTests.swift; sourceTree = ""; }; 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskLoggerTests.swift; sourceTree = ""; }; + 2ED83780236A19A60008C01F /* OSFileHandle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSFileHandle.swift; sourceTree = ""; }; 2EDA8AE8213ACCFF00FE5840 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; /* End PBXFileReference section */ @@ -149,6 +151,7 @@ 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */, 2EBF4B562122B598008E4117 /* Logrotate.swift */, 2ED077DA2132B0320058EEFC /* OSFileManager.swift */, + 2ED83780236A19A60008C01F /* OSFileHandle.swift */, ); path = DiskLogger; sourceTree = ""; @@ -259,6 +262,7 @@ buildActionMask = 2147483647; files = ( 2EBF4B582122B598008E4117 /* SizeLimitedFile.swift in Sources */, + 2ED83781236A19A60008C01F /* OSFileHandle.swift in Sources */, 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */, 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */, 2EBF4B3E2122AA34008E4117 /* Logger.swift in Sources */, diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index 3ffc4e2..395ba57 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -148,14 +148,7 @@ private class FileWriterFactory: SizeLimitedFileFactory { } private class FileHandleFactory: FileFactory { - func makeInstance(forWritingTo: URL) throws -> File { + func makeInstance(forWritingTo: URL) throws -> OSFileHandle { return try FileHandle(forWritingTo: forWritingTo) } } - -extension FileHandle: File { - - func swift_write(_ data: Data) throws { - try __write(data, error: ()) - } -} diff --git a/Logger/Loggers/DiskLogger/OSFileHandle.swift b/Logger/Loggers/DiskLogger/OSFileHandle.swift new file mode 100644 index 0000000..dfe5bb9 --- /dev/null +++ b/Logger/Loggers/DiskLogger/OSFileHandle.swift @@ -0,0 +1,23 @@ +// +// OSFileHandle.swift +// Logger +// +// Created by Wojciech Nagrodzki on 30/10/2019. +// Copyright © 2019 Wojciech Nagrodzki. All rights reserved. +// + +import Foundation + +protocol OSFileHandle { + func seekToEndOfFile() -> UInt64 + func swift_write(_ data: Data) throws + func synchronizeFile() + func closeFile() +} + +extension FileHandle: OSFileHandle { + + func swift_write(_ data: Data) throws { + try __write(data, error: ()) + } +} diff --git a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift index 29fc221..c93b5c0 100644 --- a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift +++ b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift @@ -24,15 +24,8 @@ import Foundation -protocol File { - func seekToEndOfFile() -> UInt64 - func swift_write(_ data: Data) throws - func synchronizeFile() - func closeFile() -} - protocol FileFactory { - func makeInstance(forWritingTo: URL) throws -> File + func makeInstance(forWritingTo: URL) throws -> OSFileHandle } /// Write failed as allowed size limit would be exceeded. @@ -55,7 +48,7 @@ protocol SizeLimitedFile { /// Allows writing to a file while respecting allowed size limit. final class SizeLimitedFileImpl { - private let file: File + private let file: OSFileHandle private let sizeLimit: UInt64 private var currentSize: UInt64 diff --git a/UnitTests/SizeLimitedFileTests.swift b/UnitTests/SizeLimitedFileTests.swift index c6e7987..e65dde0 100644 --- a/UnitTests/SizeLimitedFileTests.swift +++ b/UnitTests/SizeLimitedFileTests.swift @@ -69,7 +69,7 @@ private class UnopenableFileFactory: FileFactory { struct OpenFileError: Error {} - func makeInstance(forWritingTo: URL) throws -> File { + func makeInstance(forWritingTo: URL) throws -> OSFileHandle { throw OpenFileError() } } @@ -78,12 +78,12 @@ private class FileMockFactory: FileFactory { let mock = FileMock() - func makeInstance(forWritingTo: URL) throws -> File { + func makeInstance(forWritingTo: URL) throws -> OSFileHandle { return mock } } -private class FileMock: File { +private class FileMock: OSFileHandle { private(set) var writtenData = Data() private(set) var synchronizeFileCallCount = 0 From b49971f8398dd3ea55ed13e33f7be8cf55b820bc Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 20:27:33 +0100 Subject: [PATCH 07/16] Rename FileFactory to FileHandleFactory --- Logger/Loggers/DiskLogger/DiskLogger.swift | 4 ++-- Logger/Loggers/DiskLogger/SizeLimitedFile.swift | 4 ++-- UnitTests/SizeLimitedFileTests.swift | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index 395ba57..667643d 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -143,11 +143,11 @@ private class FileRotateFactory: LogrotateFactory { private class FileWriterFactory: SizeLimitedFileFactory { func makeInstance(fileURL: URL, fileSizeLimit: UInt64) throws -> SizeLimitedFile { - return try SizeLimitedFileImpl(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactory()) + return try SizeLimitedFileImpl(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactoryImpl()) } } -private class FileHandleFactory: FileFactory { +private class FileHandleFactoryImpl: FileHandleFactory { func makeInstance(forWritingTo: URL) throws -> OSFileHandle { return try FileHandle(forWritingTo: forWritingTo) } diff --git a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift index c93b5c0..d95e5f4 100644 --- a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift +++ b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift @@ -24,7 +24,7 @@ import Foundation -protocol FileFactory { +protocol FileHandleFactory { func makeInstance(forWritingTo: URL) throws -> OSFileHandle } @@ -58,7 +58,7 @@ final class SizeLimitedFileImpl { /// - fileURL: URL of the file. /// - fileSizeLimit: Maximum size the file can reach in bytes. /// - Throws: An error that may occur while the file is being opened for writing. - init(fileURL: URL, fileSizeLimit: UInt64, fileFactory: FileFactory) throws { + init(fileURL: URL, fileSizeLimit: UInt64, fileFactory: FileHandleFactory) throws { file = try fileFactory.makeInstance(forWritingTo: fileURL) self.sizeLimit = fileSizeLimit currentSize = file.seekToEndOfFile() diff --git a/UnitTests/SizeLimitedFileTests.swift b/UnitTests/SizeLimitedFileTests.swift index e65dde0..a51f3fc 100644 --- a/UnitTests/SizeLimitedFileTests.swift +++ b/UnitTests/SizeLimitedFileTests.swift @@ -65,7 +65,7 @@ class SizeLimitedFileTests: XCTestCase { } } -private class UnopenableFileFactory: FileFactory { +private class UnopenableFileFactory: FileHandleFactory { struct OpenFileError: Error {} @@ -74,7 +74,7 @@ private class UnopenableFileFactory: FileFactory { } } -private class FileMockFactory: FileFactory { +private class FileMockFactory: FileHandleFactory { let mock = FileMock() From 28716deefe30fec48948adebc8d633e285d6071b Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Wed, 30 Oct 2019 20:27:56 +0100 Subject: [PATCH 08/16] Rename FileRotateFactory to LogrotateFactoryImpl, and FileWriterFactory to SizeLimitedFileFactoryImpl --- Logger/Loggers/DiskLogger/DiskLogger.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index 667643d..9e14117 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -66,7 +66,7 @@ public final class DiskLogger: Logger { /// - fileSizeLimit: Maximum size log file can reach in bytes. Attempt to exceeding that limit triggers log files rotation. /// - rotations: Number of times log files are rotated before being removed. public convenience init(fileURL: URL, fileSizeLimit: UInt64, rotations: Int) { - self.init(fileURL: fileURL, fileSizeLimit: fileSizeLimit, rotations: rotations, fileManager: FileManager.default, sizeLimitedFileFactory: FileWriterFactory(), logrotateFactory: FileRotateFactory()) + self.init(fileURL: fileURL, fileSizeLimit: fileSizeLimit, rotations: rotations, fileManager: FileManager.default, sizeLimitedFileFactory: SizeLimitedFileFactoryImpl(), logrotateFactory: LogrotateFactoryImpl()) } init(fileURL: URL, fileSizeLimit: UInt64, rotations: Int, fileManager: OSFileManager, sizeLimitedFileFactory: SizeLimitedFileFactory, logrotateFactory: LogrotateFactory) { @@ -135,13 +135,13 @@ public final class DiskLogger: Logger { } } -private class FileRotateFactory: LogrotateFactory { +private class LogrotateFactoryImpl: LogrotateFactory { func makeInstance(fileURL: URL, rotations: Int) -> Logrotate { return LogrotateImpl(fileURL: fileURL, rotations: rotations, fileManager: FileManager.default) } } -private class FileWriterFactory: SizeLimitedFileFactory { +private class SizeLimitedFileFactoryImpl: SizeLimitedFileFactory { func makeInstance(fileURL: URL, fileSizeLimit: UInt64) throws -> SizeLimitedFile { return try SizeLimitedFileImpl(fileURL: fileURL, fileSizeLimit: fileSizeLimit, fileFactory: FileHandleFactoryImpl()) } From 04ab08f29486b0ab35245986bd0b200b93e85d33 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Mon, 4 Nov 2019 19:21:53 +0100 Subject: [PATCH 09/16] Use new FileHandle methods that throw errors instead of exceptions --- Logger.xcodeproj/project.pbxproj | 4 +- Logger/Loggers/DiskLogger/DiskLogger.swift | 7 ++-- Logger/Loggers/DiskLogger/OSFileHandle.swift | 42 ++++++++++++++++--- .../Loggers/DiskLogger/SizeLimitedFile.swift | 12 +++--- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj index 317817a..220338c 100644 --- a/Logger.xcodeproj/project.pbxproj +++ b/Logger.xcodeproj/project.pbxproj @@ -370,7 +370,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -425,7 +425,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Logger/Loggers/DiskLogger/DiskLogger.swift index 9e14117..69e5320 100644 --- a/Logger/Loggers/DiskLogger/DiskLogger.swift +++ b/Logger/Loggers/DiskLogger/DiskLogger.swift @@ -46,6 +46,7 @@ protocol LogrotateFactory { } /// Logger that writes messages into the file at specified URL with log rotation support. +@available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public final class DiskLogger: Logger { private let fileURL: URL @@ -97,7 +98,7 @@ public final class DiskLogger: Logger { try self.writeBuffer() } catch is SizeLimitedFileQuotaReached { - self.closeSizeLimitedFile() + try self.closeSizeLimitedFile() try self.rotateLogFiles() try self.openSizeLimitedFile() try self.writeBuffer() @@ -124,8 +125,8 @@ public final class DiskLogger: Logger { buffer.removeAll() } - private func closeSizeLimitedFile() { - self.sizeLimitedFile.synchronizeAndCloseFile() + private func closeSizeLimitedFile() throws { + try self.sizeLimitedFile.synchronizeAndCloseFile() self.sizeLimitedFile = nil } diff --git a/Logger/Loggers/DiskLogger/OSFileHandle.swift b/Logger/Loggers/DiskLogger/OSFileHandle.swift index dfe5bb9..3f9103a 100644 --- a/Logger/Loggers/DiskLogger/OSFileHandle.swift +++ b/Logger/Loggers/DiskLogger/OSFileHandle.swift @@ -9,15 +9,45 @@ import Foundation protocol OSFileHandle { - func seekToEndOfFile() -> UInt64 - func swift_write(_ data: Data) throws - func synchronizeFile() - func closeFile() + func osSeekToEndOfFile() throws -> UInt64 + func osWrite(_ data: Data) throws + func osSynchronizeFile() throws + func osCloseFile() throws } extension FileHandle: OSFileHandle { - func swift_write(_ data: Data) throws { - try __write(data, error: ()) + func osSeekToEndOfFile() throws -> UInt64 { + if #available(iOS 13.0, *) { + var offsetInFile: UInt64 = 0 + try __seek(toEndReturningOffset:&offsetInFile) + return offsetInFile + } else { + fatalError() + } + } + + func osWrite(_ data: Data) throws { + if #available(iOS 13.0, *) { + try __write(data, error: ()) + } else { + fatalError() + } + } + + func osSynchronizeFile() throws { + if #available(iOS 13.0, *) { + try synchronize() + } else { + fatalError() + } + } + + func osCloseFile() throws { + if #available(iOS 13.0, *) { + try close() + } else { + fatalError() + } } } diff --git a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift index d95e5f4..e7b89cb 100644 --- a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift +++ b/Logger/Loggers/DiskLogger/SizeLimitedFile.swift @@ -42,7 +42,7 @@ protocol SizeLimitedFile { func write(_ data: Data) throws /// Writes all in-memory data to permanent storage and closes the file. - func synchronizeAndCloseFile() + func synchronizeAndCloseFile() throws } /// Allows writing to a file while respecting allowed size limit. @@ -61,7 +61,7 @@ final class SizeLimitedFileImpl { init(fileURL: URL, fileSizeLimit: UInt64, fileFactory: FileHandleFactory) throws { file = try fileFactory.makeInstance(forWritingTo: fileURL) self.sizeLimit = fileSizeLimit - currentSize = file.seekToEndOfFile() + currentSize = try file.osSeekToEndOfFile() } } @@ -72,12 +72,12 @@ extension SizeLimitedFileImpl: SizeLimitedFile { guard currentSize + dataSize <= sizeLimit else { throw SizeLimitedFileQuotaReached() } - try file.swift_write(data) + try file.osWrite(data) currentSize += dataSize } - func synchronizeAndCloseFile() { - file.synchronizeFile() - file.closeFile() + func synchronizeAndCloseFile() throws { + try file.osSynchronizeFile() + try file.osCloseFile() } } From 59e25369e668861e3c65044a21de4a2f62e6c843 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Mon, 4 Nov 2019 19:22:36 +0100 Subject: [PATCH 10/16] Update DiskLogger tests to use new API --- Logger/Loggers/DiskLogger/OSFileHandle.swift | 8 +- UnitTests/DiskLoggerTests.swift | 160 ++++++++++--------- UnitTests/SizeLimitedFileTests.swift | 10 +- 3 files changed, 92 insertions(+), 86 deletions(-) diff --git a/Logger/Loggers/DiskLogger/OSFileHandle.swift b/Logger/Loggers/DiskLogger/OSFileHandle.swift index 3f9103a..34965bb 100644 --- a/Logger/Loggers/DiskLogger/OSFileHandle.swift +++ b/Logger/Loggers/DiskLogger/OSFileHandle.swift @@ -18,7 +18,7 @@ protocol OSFileHandle { extension FileHandle: OSFileHandle { func osSeekToEndOfFile() throws -> UInt64 { - if #available(iOS 13.0, *) { + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { var offsetInFile: UInt64 = 0 try __seek(toEndReturningOffset:&offsetInFile) return offsetInFile @@ -28,7 +28,7 @@ extension FileHandle: OSFileHandle { } func osWrite(_ data: Data) throws { - if #available(iOS 13.0, *) { + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { try __write(data, error: ()) } else { fatalError() @@ -36,7 +36,7 @@ extension FileHandle: OSFileHandle { } func osSynchronizeFile() throws { - if #available(iOS 13.0, *) { + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { try synchronize() } else { fatalError() @@ -44,7 +44,7 @@ extension FileHandle: OSFileHandle { } func osCloseFile() throws { - if #available(iOS 13.0, *) { + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { try close() } else { fatalError() diff --git a/UnitTests/DiskLoggerTests.swift b/UnitTests/DiskLoggerTests.swift index 4a08210..3748884 100644 --- a/UnitTests/DiskLoggerTests.swift +++ b/UnitTests/DiskLoggerTests.swift @@ -30,89 +30,95 @@ class DiskLoggerTests: XCTestCase { let logURL = URL(fileURLWithPath: "/var/log/application.log") func testLoggingMessageToFile() { - let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") - expectation.expectedFulfillmentCount = 1 - - let fimeManager = FileManagerStub() - let sizeLimitedFileFactory = SizeLimitedFileMockFactory(writeCall: expectation) - let logrotateFactory = LogrotateMockFactory() - let logger = DiskLogger(fileURL: logURL, - fileSizeLimit: 1024, - rotations: 1, - fileManager: fimeManager, - sizeLimitedFileFactory: sizeLimitedFileFactory, - logrotateFactory: logrotateFactory) - - logger.log("message", level: .critical) - - let result = XCTWaiter().wait(for: [expectation], timeout: 1.0) - XCTAssertEqual(result, .completed) - - XCTAssertEqual(sizeLimitedFileFactory.files.count, 1) - - // "2018-08-30 17:23:11.514 DiskLoggerTests:46 testWritingMessageToFile() a message\n" - let loggedMessage = String(decoding: sizeLimitedFileFactory.files[0].data, as: UTF8.self) - let expectedSuffix = " DiskLoggerTests:46 testLoggingMessageToFile() message\n" - - XCTAssertTrue(loggedMessage.hasSuffix(expectedSuffix)) + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { + let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") + expectation.expectedFulfillmentCount = 1 + + let fimeManager = FileManagerStub() + let sizeLimitedFileFactory = SizeLimitedFileMockFactory(writeCall: expectation) + let logrotateFactory = LogrotateMockFactory() + let logger = DiskLogger(fileURL: logURL, + fileSizeLimit: 1024, + rotations: 1, + fileManager: fimeManager, + sizeLimitedFileFactory: sizeLimitedFileFactory, + logrotateFactory: logrotateFactory) + + logger.log("message", level: .critical) + + let result = XCTWaiter().wait(for: [expectation], timeout: 1.0) + XCTAssertEqual(result, .completed) + + XCTAssertEqual(sizeLimitedFileFactory.files.count, 1) + + // "2018-08-30 17:23:11.514 DiskLoggerTests:46 testWritingMessageToFile() a message\n" + let loggedMessage = String(decoding: sizeLimitedFileFactory.files[0].data, as: UTF8.self) + let expectedSuffix = " DiskLoggerTests:47 testLoggingMessageToFile() message\n" + + XCTAssertTrue(loggedMessage.hasSuffix(expectedSuffix)) + } } func testExceedingFileSizeLimit() { - let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") - expectation.expectedFulfillmentCount = 2 - - let fimeManager = FileManagerStub() - let sizeLimitedFileFactory = SizeLimitedFileMockFactory(writeCall: expectation) - let logrotateFactory = LogrotateMockFactory() - let logger = DiskLogger(fileURL: logURL, - fileSizeLimit: 91, - rotations: 1, - fileManager: fimeManager, - sizeLimitedFileFactory: sizeLimitedFileFactory, - logrotateFactory: logrotateFactory) - - logger.log("1st message", level: .critical) - logger.log("2st message", level: .critical) - - let result = XCTWaiter().wait(for: [expectation], timeout: 1.0) - XCTAssertEqual(result, .completed) - - XCTAssertEqual(sizeLimitedFileFactory.files.count, 2) - - // "2018-08-31 18:29:34.748 DiskLoggerTests:75 testExceedingFileSizeLimit() 2st message\n" - let loggedMessage = String(decoding: sizeLimitedFileFactory.files[1].data, as: UTF8.self) - let expectedSuffix = " DiskLoggerTests:75 testExceedingFileSizeLimit() 2st message\n" - - XCTAssertTrue(loggedMessage.hasSuffix(expectedSuffix)) + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { + let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") + expectation.expectedFulfillmentCount = 2 + + let fimeManager = FileManagerStub() + let sizeLimitedFileFactory = SizeLimitedFileMockFactory(writeCall: expectation) + let logrotateFactory = LogrotateMockFactory() + let logger = DiskLogger(fileURL: logURL, + fileSizeLimit: 91, + rotations: 1, + fileManager: fimeManager, + sizeLimitedFileFactory: sizeLimitedFileFactory, + logrotateFactory: logrotateFactory) + + logger.log("1st message", level: .critical) + logger.log("2st message", level: .critical) + + let result = XCTWaiter().wait(for: [expectation], timeout: 1.0) + XCTAssertEqual(result, .completed) + + XCTAssertEqual(sizeLimitedFileFactory.files.count, 2) + + // "2018-08-31 18:29:34.748 DiskLoggerTests:75 testExceedingFileSizeLimit() 2st message\n" + let loggedMessage = String(decoding: sizeLimitedFileFactory.files[1].data, as: UTF8.self) + let expectedSuffix = " DiskLoggerTests:78 testExceedingFileSizeLimit() 2st message\n" + + XCTAssertTrue(loggedMessage.hasSuffix(expectedSuffix)) + } } func testErrorDuringLogProcess() { - let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") - expectation.expectedFulfillmentCount = 2 - - let fimeManager = FileManagerStub() - let sizeLimitedFileFactory = UnwritableFileStubFactory(writeCall: expectation) - let logrotateFactory = LogrotateMockFactory() - let logger = DiskLogger(fileURL: logURL, - fileSizeLimit: 91, - rotations: 1, - fileManager: fimeManager, - sizeLimitedFileFactory: sizeLimitedFileFactory, - logrotateFactory: logrotateFactory) - - logger.log("1st message", level: .critical) - logger.log("2st message", level: .critical) - - let result = XCTWaiter().wait(for: [expectation], timeout: 1.0) - XCTAssertEqual(result, .completed) - - XCTAssertEqual(sizeLimitedFileFactory.files.count, 1) - - // "2018-08-31 18:29:34.748 DiskLoggerTests:75 testExceedingFileSizeLimit() 2st message\n" - let loggedMessage = String(decoding: sizeLimitedFileFactory.files[0].data, as: UTF8.self) - let expectedOccurence = " WriteFailed()" - - XCTAssertTrue(loggedMessage.contains(expectedOccurence)) + if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { + let expectation = XCTestExpectation(description: "write(_:) was called on SizeLimitedFile") + expectation.expectedFulfillmentCount = 2 + + let fimeManager = FileManagerStub() + let sizeLimitedFileFactory = UnwritableFileStubFactory(writeCall: expectation) + let logrotateFactory = LogrotateMockFactory() + let logger = DiskLogger(fileURL: logURL, + fileSizeLimit: 91, + rotations: 1, + fileManager: fimeManager, + sizeLimitedFileFactory: sizeLimitedFileFactory, + logrotateFactory: logrotateFactory) + + logger.log("1st message", level: .critical) + logger.log("2st message", level: .critical) + + let result = XCTWaiter().wait(for: [expectation], timeout: 1.0) + XCTAssertEqual(result, .completed) + + XCTAssertEqual(sizeLimitedFileFactory.files.count, 1) + + // "2018-08-31 18:29:34.748 DiskLoggerTests:75 testExceedingFileSizeLimit() 2st message\n" + let loggedMessage = String(decoding: sizeLimitedFileFactory.files[0].data, as: UTF8.self) + let expectedOccurence = " WriteFailed()" + + XCTAssertTrue(loggedMessage.contains(expectedOccurence)) + } } } diff --git a/UnitTests/SizeLimitedFileTests.swift b/UnitTests/SizeLimitedFileTests.swift index a51f3fc..83db64b 100644 --- a/UnitTests/SizeLimitedFileTests.swift +++ b/UnitTests/SizeLimitedFileTests.swift @@ -60,7 +60,7 @@ class SizeLimitedFileTests: XCTestCase { func testSynchronizingAndClosingFile() throws { let factory = FileMockFactory() let writer = try SizeLimitedFileImpl(fileURL: logURL, fileSizeLimit: 1, fileFactory: factory) - writer.synchronizeAndCloseFile() + try writer.synchronizeAndCloseFile() XCTAssertTrue(factory.mock.synchronizeFileCallCount == 1 && factory.mock.closeFileCallCount == 1) } } @@ -89,19 +89,19 @@ private class FileMock: OSFileHandle { private(set) var synchronizeFileCallCount = 0 private(set) var closeFileCallCount = 0 - func seekToEndOfFile() -> UInt64 { + func osSeekToEndOfFile() throws -> UInt64 { return 0 } - func swift_write(_ data: Data) throws { + func osWrite(_ data: Data) throws { self.writtenData.append(data) } - func synchronizeFile() { + func osSynchronizeFile() throws { synchronizeFileCallCount += 1 } - func closeFile() { + func osCloseFile() throws { closeFileCallCount += 1 } } From d9c958bb3bebc602b1b9ce2a47ac7996ea1ee66a Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Mon, 4 Nov 2019 20:31:17 +0100 Subject: [PATCH 11/16] Update travis-ci configuration file --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 073ed9c..3fc4d7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: swift -osx_image: xcode10.2 +osx_image: xcode11.2 xcode_project: Logger.xcodeproj -script: xcodebuild test -project Logger.xcodeproj -scheme Logger -destination 'platform=iOS Simulator,name=iPhone XS,OS=12.2' +script: xcodebuild test -project Logger.xcodeproj -scheme Logger -destination 'platform=iOS Simulator,name=iPhone 11,OS=13.2' after_success: bash <(curl -s https://codecov.io/bash) \ No newline at end of file From 953c22eb77b493bbb47253e59a5a62a3ff50f9f5 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Tue, 5 Nov 2019 18:22:27 +0100 Subject: [PATCH 12/16] Update gitignore to take into account macOS files and directories --- .gitignore | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 312d1f6..62ce0ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,36 @@ + +# Created by https://www.gitignore.io/api/swift,xcode,macos +# Edit at https://www.gitignore.io/?templates=swift,xcode,macos + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Swift ### # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore @@ -33,30 +66,33 @@ timeline.xctimeline playground.xcworkspace # Swift Package Manager -# # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. # Packages/ # Package.pins # Package.resolved .build/ +# Add this line if you want to avoid checking in Xcode SPM integration. +# .swiftpm/xcode # CocoaPods -# # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# # Pods/ +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace # Carthage -# # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts Carthage/Build +# Accio dependency management +Dependencies/ +.accio/ + # fastlane -# # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the # screenshots whenever they are needed. # For more information about the recommended setup visit: @@ -66,3 +102,31 @@ fastlane/report.xml fastlane/Preview.html fastlane/screenshots/**/*.png fastlane/test_output + +# Code Injection +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +### Xcode ### +# Xcode +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) + +## Xcode Patch +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +/*.gcno + +### Xcode Patch ### +**/xcshareddata/WorkspaceSettings.xcsettings + +# End of https://www.gitignore.io/api/swift,xcode,macos From 6abe3e20926b89cb3fe0df9e76759d166cd4041e Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Tue, 5 Nov 2019 18:37:11 +0100 Subject: [PATCH 13/16] Convert Xcode project to Swift package --- Logger.xcodeproj/project.pbxproj | 508 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../xcshareddata/xcschemes/Logger.xcscheme | 100 ---- Package.swift | 24 + .../SwiftLogger}/LogStringConvertible.swift | 0 {Logger => Sources/SwiftLogger}/Logger.swift | 0 .../SwiftLogger}/Loggers/AgregateLogger.swift | 0 .../SwiftLogger}/Loggers/ConsoleLogger.swift | 0 .../Loggers/DiskLogger/DiskLogger.swift | 0 .../Loggers/DiskLogger/Logrotate.swift | 0 .../Loggers/DiskLogger/OSFileHandle.swift | 0 .../Loggers/DiskLogger/OSFileManager.swift | 0 .../Loggers/DiskLogger/SizeLimitedFile.swift | 0 .../SwiftLogger}/Loggers/NullLogger.swift | 0 Tests/LinuxMain.swift | 7 + .../AgregateLoggerTests.swift | 2 +- .../SwiftLoggerTests}/DiskLoggerTests.swift | 2 +- .../LogStringConvertibleTests.swift | 2 +- .../SwiftLoggerTests}/LoggetTests.swift | 2 +- .../SwiftLoggerTests}/LogrotateTests.swift | 2 +- .../SizeLimitedFileTests.swift | 2 +- Tests/SwiftLoggerTests/XCTestManifests.swift | 9 + UnitTests/Info.plist | 22 - 24 files changed, 46 insertions(+), 651 deletions(-) delete mode 100644 Logger.xcodeproj/project.pbxproj delete mode 100644 Logger.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Logger.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Logger.xcodeproj/xcshareddata/xcschemes/Logger.xcscheme create mode 100644 Package.swift rename {Logger => Sources/SwiftLogger}/LogStringConvertible.swift (100%) rename {Logger => Sources/SwiftLogger}/Logger.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/AgregateLogger.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/ConsoleLogger.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/DiskLogger/DiskLogger.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/DiskLogger/Logrotate.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/DiskLogger/OSFileHandle.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/DiskLogger/OSFileManager.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/DiskLogger/SizeLimitedFile.swift (100%) rename {Logger => Sources/SwiftLogger}/Loggers/NullLogger.swift (100%) create mode 100644 Tests/LinuxMain.swift rename {UnitTests => Tests/SwiftLoggerTests}/AgregateLoggerTests.swift (98%) rename {UnitTests => Tests/SwiftLoggerTests}/DiskLoggerTests.swift (99%) rename {UnitTests => Tests/SwiftLoggerTests}/LogStringConvertibleTests.swift (98%) rename {UnitTests => Tests/SwiftLoggerTests}/LoggetTests.swift (98%) rename {UnitTests => Tests/SwiftLoggerTests}/LogrotateTests.swift (99%) rename {UnitTests => Tests/SwiftLoggerTests}/SizeLimitedFileTests.swift (99%) create mode 100644 Tests/SwiftLoggerTests/XCTestManifests.swift delete mode 100644 UnitTests/Info.plist diff --git a/Logger.xcodeproj/project.pbxproj b/Logger.xcodeproj/project.pbxproj deleted file mode 100644 index 220338c..0000000 --- a/Logger.xcodeproj/project.pbxproj +++ /dev/null @@ -1,508 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 2E58D35D21316C3500BEF81A /* LogStringConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E58D35C21316C3500BEF81A /* LogStringConvertibleTests.swift */; }; - 2E58D35F21316C3500BEF81A /* libLogger.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2EBF4B3A2122AA34008E4117 /* libLogger.a */; }; - 2EBF4B3E2122AA34008E4117 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B3D2122AA34008E4117 /* Logger.swift */; }; - 2EBF4B452122ACD6008E4117 /* LogStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B442122ACD6008E4117 /* LogStringConvertible.swift */; }; - 2EBF4B4A2122AF53008E4117 /* AgregateLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B472122AF53008E4117 /* AgregateLogger.swift */; }; - 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */; }; - 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B492122AF53008E4117 /* NullLogger.swift */; }; - 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B542122B598008E4117 /* DiskLogger.swift */; }; - 2EBF4B582122B598008E4117 /* SizeLimitedFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */; }; - 2EBF4B592122B598008E4117 /* Logrotate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBF4B562122B598008E4117 /* Logrotate.swift */; }; - 2ED077D721329CA30058EEFC /* LoggetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D621329CA30058EEFC /* LoggetTests.swift */; }; - 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */; }; - 2ED077DB2132B0320058EEFC /* OSFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED077DA2132B0320058EEFC /* OSFileManager.swift */; }; - 2ED103E12135C61100EB3683 /* LogrotateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E02135C61100EB3683 /* LogrotateTests.swift */; }; - 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */; }; - 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */; }; - 2ED83781236A19A60008C01F /* OSFileHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2ED83780236A19A60008C01F /* OSFileHandle.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 2E58D36021316C3500BEF81A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 2EBF4B322122AA34008E4117 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 2EBF4B392122AA34008E4117; - remoteInfo = Logger; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 2EBF4B382122AA34008E4117 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 2E58D35A21316C3500BEF81A /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 2E58D35C21316C3500BEF81A /* LogStringConvertibleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogStringConvertibleTests.swift; sourceTree = ""; }; - 2E58D35E21316C3500BEF81A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 2EBF4B3A2122AA34008E4117 /* libLogger.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLogger.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 2EBF4B3D2122AA34008E4117 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; }; - 2EBF4B442122ACD6008E4117 /* LogStringConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogStringConvertible.swift; sourceTree = ""; }; - 2EBF4B472122AF53008E4117 /* AgregateLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgregateLogger.swift; sourceTree = ""; }; - 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConsoleLogger.swift; sourceTree = ""; }; - 2EBF4B492122AF53008E4117 /* NullLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NullLogger.swift; sourceTree = ""; }; - 2EBF4B542122B598008E4117 /* DiskLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiskLogger.swift; sourceTree = ""; }; - 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SizeLimitedFile.swift; sourceTree = ""; }; - 2EBF4B562122B598008E4117 /* Logrotate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logrotate.swift; sourceTree = ""; }; - 2ED077D621329CA30058EEFC /* LoggetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggetTests.swift; sourceTree = ""; }; - 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgregateLoggerTests.swift; sourceTree = ""; }; - 2ED077DA2132B0320058EEFC /* OSFileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSFileManager.swift; sourceTree = ""; }; - 2ED103E02135C61100EB3683 /* LogrotateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogrotateTests.swift; sourceTree = ""; }; - 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeLimitedFileTests.swift; sourceTree = ""; }; - 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskLoggerTests.swift; sourceTree = ""; }; - 2ED83780236A19A60008C01F /* OSFileHandle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSFileHandle.swift; sourceTree = ""; }; - 2EDA8AE8213ACCFF00FE5840 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 2E58D35721316C3500BEF81A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 2E58D35F21316C3500BEF81A /* libLogger.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2EBF4B372122AA34008E4117 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 2E58D35B21316C3500BEF81A /* UnitTests */ = { - isa = PBXGroup; - children = ( - 2E58D35C21316C3500BEF81A /* LogStringConvertibleTests.swift */, - 2ED077D621329CA30058EEFC /* LoggetTests.swift */, - 2ED077D82132A4820058EEFC /* AgregateLoggerTests.swift */, - 2ED103E42138553B00EB3683 /* DiskLoggerTests.swift */, - 2ED103E22135D3FB00EB3683 /* SizeLimitedFileTests.swift */, - 2ED103E02135C61100EB3683 /* LogrotateTests.swift */, - 2E58D35E21316C3500BEF81A /* Info.plist */, - ); - path = UnitTests; - sourceTree = ""; - }; - 2EBF4B312122AA34008E4117 = { - isa = PBXGroup; - children = ( - 2EDA8AE8213ACCFF00FE5840 /* README.md */, - 2EBF4B3C2122AA34008E4117 /* Logger */, - 2E58D35B21316C3500BEF81A /* UnitTests */, - 2EBF4B3B2122AA34008E4117 /* Products */, - ); - sourceTree = ""; - }; - 2EBF4B3B2122AA34008E4117 /* Products */ = { - isa = PBXGroup; - children = ( - 2EBF4B3A2122AA34008E4117 /* libLogger.a */, - 2E58D35A21316C3500BEF81A /* UnitTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 2EBF4B3C2122AA34008E4117 /* Logger */ = { - isa = PBXGroup; - children = ( - 2EBF4B442122ACD6008E4117 /* LogStringConvertible.swift */, - 2EBF4B3D2122AA34008E4117 /* Logger.swift */, - 2EBF4B462122AF53008E4117 /* Loggers */, - ); - path = Logger; - sourceTree = ""; - }; - 2EBF4B462122AF53008E4117 /* Loggers */ = { - isa = PBXGroup; - children = ( - 2EBF4B472122AF53008E4117 /* AgregateLogger.swift */, - 2EBF4B482122AF53008E4117 /* ConsoleLogger.swift */, - 2EBF4B492122AF53008E4117 /* NullLogger.swift */, - 2EBF4B4D2122B034008E4117 /* DiskLogger */, - ); - path = Loggers; - sourceTree = ""; - }; - 2EBF4B4D2122B034008E4117 /* DiskLogger */ = { - isa = PBXGroup; - children = ( - 2EBF4B542122B598008E4117 /* DiskLogger.swift */, - 2EBF4B552122B598008E4117 /* SizeLimitedFile.swift */, - 2EBF4B562122B598008E4117 /* Logrotate.swift */, - 2ED077DA2132B0320058EEFC /* OSFileManager.swift */, - 2ED83780236A19A60008C01F /* OSFileHandle.swift */, - ); - path = DiskLogger; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 2E58D35921316C3500BEF81A /* UnitTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2E58D36221316C3500BEF81A /* Build configuration list for PBXNativeTarget "UnitTests" */; - buildPhases = ( - 2E58D35621316C3500BEF81A /* Sources */, - 2E58D35721316C3500BEF81A /* Frameworks */, - 2E58D35821316C3500BEF81A /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 2E58D36121316C3500BEF81A /* PBXTargetDependency */, - ); - name = UnitTests; - productName = UnitTests; - productReference = 2E58D35A21316C3500BEF81A /* UnitTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 2EBF4B392122AA34008E4117 /* Logger */ = { - isa = PBXNativeTarget; - buildConfigurationList = 2EBF4B412122AA34008E4117 /* Build configuration list for PBXNativeTarget "Logger" */; - buildPhases = ( - 2EBF4B362122AA34008E4117 /* Sources */, - 2EBF4B372122AA34008E4117 /* Frameworks */, - 2EBF4B382122AA34008E4117 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Logger; - productName = Logger; - productReference = 2EBF4B3A2122AA34008E4117 /* libLogger.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 2EBF4B322122AA34008E4117 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1000; - LastUpgradeCheck = 1000; - ORGANIZATIONNAME = "Wojciech Nagrodzki"; - TargetAttributes = { - 2E58D35921316C3500BEF81A = { - CreatedOnToolsVersion = 10.0; - LastSwiftMigration = 1020; - }; - 2EBF4B392122AA34008E4117 = { - CreatedOnToolsVersion = 10.0; - LastSwiftMigration = 1020; - }; - }; - }; - buildConfigurationList = 2EBF4B352122AA34008E4117 /* Build configuration list for PBXProject "Logger" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 2EBF4B312122AA34008E4117; - productRefGroup = 2EBF4B3B2122AA34008E4117 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 2EBF4B392122AA34008E4117 /* Logger */, - 2E58D35921316C3500BEF81A /* UnitTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 2E58D35821316C3500BEF81A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 2E58D35621316C3500BEF81A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2E58D35D21316C3500BEF81A /* LogStringConvertibleTests.swift in Sources */, - 2ED103E32135D3FB00EB3683 /* SizeLimitedFileTests.swift in Sources */, - 2ED103E52138553B00EB3683 /* DiskLoggerTests.swift in Sources */, - 2ED077D92132A4820058EEFC /* AgregateLoggerTests.swift in Sources */, - 2ED103E12135C61100EB3683 /* LogrotateTests.swift in Sources */, - 2ED077D721329CA30058EEFC /* LoggetTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 2EBF4B362122AA34008E4117 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2EBF4B582122B598008E4117 /* SizeLimitedFile.swift in Sources */, - 2ED83781236A19A60008C01F /* OSFileHandle.swift in Sources */, - 2EBF4B572122B598008E4117 /* DiskLogger.swift in Sources */, - 2EBF4B4C2122AF53008E4117 /* NullLogger.swift in Sources */, - 2EBF4B3E2122AA34008E4117 /* Logger.swift in Sources */, - 2EBF4B4B2122AF53008E4117 /* ConsoleLogger.swift in Sources */, - 2ED077DB2132B0320058EEFC /* OSFileManager.swift in Sources */, - 2EBF4B4A2122AF53008E4117 /* AgregateLogger.swift in Sources */, - 2EBF4B592122B598008E4117 /* Logrotate.swift in Sources */, - 2EBF4B452122ACD6008E4117 /* LogStringConvertible.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 2E58D36121316C3500BEF81A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 2EBF4B392122AA34008E4117 /* Logger */; - targetProxy = 2E58D36021316C3500BEF81A /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 2E58D36321316C3500BEF81A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - INFOPLIST_FILE = UnitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.wnagrodzki.UnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 2E58D36421316C3500BEF81A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - INFOPLIST_FILE = UnitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.wnagrodzki.UnitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; - 2EBF4B3F2122AA34008E4117 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 2EBF4B402122AA34008E4117 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 2EBF4B422122AA34008E4117 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 2EBF4B432122AA34008E4117 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Automatic; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 2E58D36221316C3500BEF81A /* Build configuration list for PBXNativeTarget "UnitTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2E58D36321316C3500BEF81A /* Debug */, - 2E58D36421316C3500BEF81A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2EBF4B352122AA34008E4117 /* Build configuration list for PBXProject "Logger" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2EBF4B3F2122AA34008E4117 /* Debug */, - 2EBF4B402122AA34008E4117 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 2EBF4B412122AA34008E4117 /* Build configuration list for PBXNativeTarget "Logger" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 2EBF4B422122AA34008E4117 /* Debug */, - 2EBF4B432122AA34008E4117 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 2EBF4B322122AA34008E4117 /* Project object */; -} diff --git a/Logger.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Logger.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 0ca1195..0000000 --- a/Logger.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Logger.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Logger.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Logger.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Logger.xcodeproj/xcshareddata/xcschemes/Logger.xcscheme b/Logger.xcodeproj/xcshareddata/xcschemes/Logger.xcscheme deleted file mode 100644 index 3fdcd78..0000000 --- a/Logger.xcodeproj/xcshareddata/xcschemes/Logger.xcscheme +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..44673a3 --- /dev/null +++ b/Package.swift @@ -0,0 +1,24 @@ +// swift-tools-version:5.1 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "SwiftLogger", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "SwiftLogger", + targets: ["SwiftLogger"]), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "SwiftLogger", + dependencies: []), + .testTarget( + name: "SwiftLoggerTests", + dependencies: ["SwiftLogger"]), + ] +) diff --git a/Logger/LogStringConvertible.swift b/Sources/SwiftLogger/LogStringConvertible.swift similarity index 100% rename from Logger/LogStringConvertible.swift rename to Sources/SwiftLogger/LogStringConvertible.swift diff --git a/Logger/Logger.swift b/Sources/SwiftLogger/Logger.swift similarity index 100% rename from Logger/Logger.swift rename to Sources/SwiftLogger/Logger.swift diff --git a/Logger/Loggers/AgregateLogger.swift b/Sources/SwiftLogger/Loggers/AgregateLogger.swift similarity index 100% rename from Logger/Loggers/AgregateLogger.swift rename to Sources/SwiftLogger/Loggers/AgregateLogger.swift diff --git a/Logger/Loggers/ConsoleLogger.swift b/Sources/SwiftLogger/Loggers/ConsoleLogger.swift similarity index 100% rename from Logger/Loggers/ConsoleLogger.swift rename to Sources/SwiftLogger/Loggers/ConsoleLogger.swift diff --git a/Logger/Loggers/DiskLogger/DiskLogger.swift b/Sources/SwiftLogger/Loggers/DiskLogger/DiskLogger.swift similarity index 100% rename from Logger/Loggers/DiskLogger/DiskLogger.swift rename to Sources/SwiftLogger/Loggers/DiskLogger/DiskLogger.swift diff --git a/Logger/Loggers/DiskLogger/Logrotate.swift b/Sources/SwiftLogger/Loggers/DiskLogger/Logrotate.swift similarity index 100% rename from Logger/Loggers/DiskLogger/Logrotate.swift rename to Sources/SwiftLogger/Loggers/DiskLogger/Logrotate.swift diff --git a/Logger/Loggers/DiskLogger/OSFileHandle.swift b/Sources/SwiftLogger/Loggers/DiskLogger/OSFileHandle.swift similarity index 100% rename from Logger/Loggers/DiskLogger/OSFileHandle.swift rename to Sources/SwiftLogger/Loggers/DiskLogger/OSFileHandle.swift diff --git a/Logger/Loggers/DiskLogger/OSFileManager.swift b/Sources/SwiftLogger/Loggers/DiskLogger/OSFileManager.swift similarity index 100% rename from Logger/Loggers/DiskLogger/OSFileManager.swift rename to Sources/SwiftLogger/Loggers/DiskLogger/OSFileManager.swift diff --git a/Logger/Loggers/DiskLogger/SizeLimitedFile.swift b/Sources/SwiftLogger/Loggers/DiskLogger/SizeLimitedFile.swift similarity index 100% rename from Logger/Loggers/DiskLogger/SizeLimitedFile.swift rename to Sources/SwiftLogger/Loggers/DiskLogger/SizeLimitedFile.swift diff --git a/Logger/Loggers/NullLogger.swift b/Sources/SwiftLogger/Loggers/NullLogger.swift similarity index 100% rename from Logger/Loggers/NullLogger.swift rename to Sources/SwiftLogger/Loggers/NullLogger.swift diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..5e88a5e --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import SwiftLoggerTests + +var tests = [XCTestCaseEntry]() +tests += SwiftLoggerTests.allTests() +XCTMain(tests) diff --git a/UnitTests/AgregateLoggerTests.swift b/Tests/SwiftLoggerTests/AgregateLoggerTests.swift similarity index 98% rename from UnitTests/AgregateLoggerTests.swift rename to Tests/SwiftLoggerTests/AgregateLoggerTests.swift index c3c2704..87cb73e 100644 --- a/UnitTests/AgregateLoggerTests.swift +++ b/Tests/SwiftLoggerTests/AgregateLoggerTests.swift @@ -23,7 +23,7 @@ // import XCTest -@testable import Logger +@testable import SwiftLogger class AgregateLoggerTests: XCTestCase { diff --git a/UnitTests/DiskLoggerTests.swift b/Tests/SwiftLoggerTests/DiskLoggerTests.swift similarity index 99% rename from UnitTests/DiskLoggerTests.swift rename to Tests/SwiftLoggerTests/DiskLoggerTests.swift index 3748884..a86ad26 100644 --- a/UnitTests/DiskLoggerTests.swift +++ b/Tests/SwiftLoggerTests/DiskLoggerTests.swift @@ -23,7 +23,7 @@ // import XCTest -@testable import Logger +@testable import SwiftLogger class DiskLoggerTests: XCTestCase { diff --git a/UnitTests/LogStringConvertibleTests.swift b/Tests/SwiftLoggerTests/LogStringConvertibleTests.swift similarity index 98% rename from UnitTests/LogStringConvertibleTests.swift rename to Tests/SwiftLoggerTests/LogStringConvertibleTests.swift index 58bc9b2..4397405 100644 --- a/UnitTests/LogStringConvertibleTests.swift +++ b/Tests/SwiftLoggerTests/LogStringConvertibleTests.swift @@ -23,7 +23,7 @@ // import XCTest -@testable import Logger +@testable import SwiftLogger class LogStringConvertibleTests: XCTestCase { diff --git a/UnitTests/LoggetTests.swift b/Tests/SwiftLoggerTests/LoggetTests.swift similarity index 98% rename from UnitTests/LoggetTests.swift rename to Tests/SwiftLoggerTests/LoggetTests.swift index a753ca7..2d63a4b 100644 --- a/UnitTests/LoggetTests.swift +++ b/Tests/SwiftLoggerTests/LoggetTests.swift @@ -23,7 +23,7 @@ // import XCTest -@testable import Logger +@testable import SwiftLogger class LoggetTests: XCTestCase { diff --git a/UnitTests/LogrotateTests.swift b/Tests/SwiftLoggerTests/LogrotateTests.swift similarity index 99% rename from UnitTests/LogrotateTests.swift rename to Tests/SwiftLoggerTests/LogrotateTests.swift index 0aa968b..ae00f22 100644 --- a/UnitTests/LogrotateTests.swift +++ b/Tests/SwiftLoggerTests/LogrotateTests.swift @@ -23,7 +23,7 @@ // import XCTest -@testable import Logger +@testable import SwiftLogger class LogrotateTests: XCTestCase { diff --git a/UnitTests/SizeLimitedFileTests.swift b/Tests/SwiftLoggerTests/SizeLimitedFileTests.swift similarity index 99% rename from UnitTests/SizeLimitedFileTests.swift rename to Tests/SwiftLoggerTests/SizeLimitedFileTests.swift index 83db64b..93d82bd 100644 --- a/UnitTests/SizeLimitedFileTests.swift +++ b/Tests/SwiftLoggerTests/SizeLimitedFileTests.swift @@ -23,7 +23,7 @@ // import XCTest -@testable import Logger +@testable import SwiftLogger class SizeLimitedFileTests: XCTestCase { diff --git a/Tests/SwiftLoggerTests/XCTestManifests.swift b/Tests/SwiftLoggerTests/XCTestManifests.swift new file mode 100644 index 0000000..52deb45 --- /dev/null +++ b/Tests/SwiftLoggerTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(SwiftLoggerTests.allTests), + ] +} +#endif diff --git a/UnitTests/Info.plist b/UnitTests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/UnitTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - From db25f8a10b395f43d8db7c37d69ee4b2bcffa7bb Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Tue, 5 Nov 2019 18:38:30 +0100 Subject: [PATCH 14/16] Update travis-ci configuration file --- .travis.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3fc4d7e..0e3d00b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,11 @@ -language: swift -osx_image: xcode11.2 -xcode_project: Logger.xcodeproj -script: xcodebuild test -project Logger.xcodeproj -scheme Logger -destination 'platform=iOS Simulator,name=iPhone 11,OS=13.2' -after_success: bash <(curl -s https://codecov.io/bash) \ No newline at end of file +os: + osx +language: + swift +osx_image: + xcode11.2 +script: + - swift build + - swift test +after_success: + - bash <(curl -s https://codecov.io/bash) From deceb93eecdff33cc8611159a880746c35969973 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Tue, 5 Nov 2019 19:25:01 +0100 Subject: [PATCH 15/16] Turn "gather code coverage" option on --- .../xcschemes/SwiftLogger.xcscheme | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .swiftpm/xcode/xcshareddata/xcschemes/SwiftLogger.xcscheme diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/SwiftLogger.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/SwiftLogger.xcscheme new file mode 100644 index 0000000..0aa4bb4 --- /dev/null +++ b/.swiftpm/xcode/xcshareddata/xcschemes/SwiftLogger.xcscheme @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 93a14c91243c415020329d2cd17f3efe7bdcf047 Mon Sep 17 00:00:00 2001 From: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com> Date: Tue, 5 Nov 2019 21:13:42 +0100 Subject: [PATCH 16/16] Enable code coverage when testing swift package --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e3d00b..6708a38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,10 @@ language: osx_image: xcode11.2 script: + - sw_vers - swift build - - swift test -after_success: - - bash <(curl -s https://codecov.io/bash) + - swift test --enable-code-coverage +after_success: + - xcrun llvm-cov report .build/debug/SwiftLoggerPackageTests.xctest/Contents/MacOS/SwiftLoggerPackageTests -instr-profile .build/debug/codecov/default.profdata + - xcrun llvm-cov export -format="lcov" .build/debug/SwiftLoggerPackageTests.xctest/Contents/MacOS/SwiftLoggerPackageTests -instr-profile .build/debug/codecov/default.profdata > info.lcov + - bash <(curl https://codecov.io/bash)