diff --git a/CHANGELOG.md b/CHANGELOG.md index 6937348..d1c4f26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.1.1](https://github.com/sushichop/Puppy/releases/tag/0.1.1) (2020-10-20) + +- Fix access level issue for use as a library. #4 + ## [0.1.0](https://github.com/sushichop/Puppy/releases/tag/0.1.0) (2020-10-18) -- First release +- First release. diff --git a/Configurations/Common.xcconfig b/Configurations/Common.xcconfig index 7ff74c4..f465404 100644 --- a/Configurations/Common.xcconfig +++ b/Configurations/Common.xcconfig @@ -19,7 +19,7 @@ WATCHOS_DEPLOYMENT_TARGET = 3.0 SWIFT_VERSION = 5.0 -MARKETING_VERSION = 0.1.0 +MARKETING_VERSION = 0.1.1 DYLIB_CURRENT_VERSION = 1 CURRENT_PROJECT_VERSION = $(DYLIB_CURRENT_VERSION) diff --git a/Puppy.podspec b/Puppy.podspec index 59ad225..096216b 100644 --- a/Puppy.podspec +++ b/Puppy.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Puppy" - s.version = "0.1.0" + s.version = "0.1.1" s.summary = "A flexible logging library written in Swift" s.homepage = "https://github.com/sushichop/Puppy" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/README.md b/README.md index b0b6c96..7112d9a 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,16 @@ ## Examples -**Logging to console and file using file log rotation feature.** +**Logging to console and file, then use log rotation feature about file.** You can basically use CocoaPods, Carthage, and Swift Package Manager for integration. ```swift +import Puppy + let console = ConsoleLogger("com.example.yourapp.consolelogger") let fileURL = URL(fileURLWithPath: "./rotation/foo.log").absoluteURL -let fileRotation = try FileRotationLogger("com.example.yourapp.filerotationlogger", +let fileRotation = try! FileRotationLogger("com.example.yourapp.filerotationlogger", fileURL: fileURL) fileRotation.maxFileSize = 10 * 1024 * 1024 @@ -51,6 +53,9 @@ You can use CocoaPods and Swift Package Manager for integration. (`apple/swift-log` does not support Carthage integration.) ```swift +import Puppy +import Logging + let console = SystemLogger("com.example.yourapp.consolelogger") let syslog = SystemLogger("com.example.yourapp.systemlogger") diff --git a/Sources/Puppy/BaseLogger.swift b/Sources/Puppy/BaseLogger.swift index b70958a..18949ea 100644 --- a/Sources/Puppy/BaseLogger.swift +++ b/Sources/Puppy/BaseLogger.swift @@ -43,7 +43,7 @@ public class BaseLogger: Loggerable { public var label: String public var queue: DispatchQueue? { return nil } - init(_ label: String) { + public init(_ label: String) { self.label = label } diff --git a/Sources/Puppy/FileLogger.swift b/Sources/Puppy/FileLogger.swift index 355c3cf..d320427 100644 --- a/Sources/Puppy/FileLogger.swift +++ b/Sources/Puppy/FileLogger.swift @@ -13,7 +13,7 @@ public class FileLogger: BaseLogger { private var fileHandle: FileHandle! private let fileURL: URL - init(_ label: String, fileURL: URL) throws { + public init(_ label: String, fileURL: URL) throws { self.fileURL = fileURL debug("fileURL is \(fileURL)") super.init(label) diff --git a/Sources/Puppy/FileRotationLogger.swift b/Sources/Puppy/FileRotationLogger.swift index b083f2a..40fff9a 100644 --- a/Sources/Puppy/FileRotationLogger.swift +++ b/Sources/Puppy/FileRotationLogger.swift @@ -17,7 +17,7 @@ public class FileRotationLogger: BaseLogger { public weak var delegate: FileRotationLoggerDeletate? - init(_ label: String, fileURL: URL) throws { + public init(_ label: String, fileURL: URL) throws { self.fileURL = fileURL debug("fileURL is \(fileURL)") super.init(label) diff --git a/Sources/Puppy/Formatter.swift b/Sources/Puppy/Formatter.swift index 7757602..7d66251 100644 --- a/Sources/Puppy/Formatter.swift +++ b/Sources/Puppy/Formatter.swift @@ -5,12 +5,12 @@ public protocol LogFormattable { } extension LogFormattable { - func shortFileName(_ file: String) -> String { + public func shortFileName(_ file: String) -> String { return URL(fileURLWithPath: file).lastPathComponent } } -func dateFormatter(_ date: Date, locale: String = "en_US_POSIX", dateFormat: String = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", timeZone: String = "") -> String { +public func dateFormatter(_ date: Date, locale: String = "en_US_POSIX", dateFormat: String = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", timeZone: String = "") -> String { let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: locale) dateFormatter.dateFormat = dateFormat diff --git a/Sources/Puppy/LogLevel.swift b/Sources/Puppy/LogLevel.swift index e5386d2..ea38f06 100644 --- a/Sources/Puppy/LogLevel.swift +++ b/Sources/Puppy/LogLevel.swift @@ -35,7 +35,7 @@ extension LogLevel: CustomStringConvertible { } extension LogLevel { - var emoji: String { + public var emoji: String { switch self { case .trace: return "🟤" @@ -56,7 +56,7 @@ extension LogLevel { } } - var color: LogColor { + public var color: LogColor { switch self { case .trace: return .darkGray diff --git a/Sources/Puppy/OSLogger.swift b/Sources/Puppy/OSLogger.swift index 9e31d7c..46493a1 100644 --- a/Sources/Puppy/OSLogger.swift +++ b/Sources/Puppy/OSLogger.swift @@ -13,7 +13,7 @@ public class OSLogger: BaseLogger { private let osLog: OSLog - init(_ label: String, category: String = "Puppy") { + public init(_ label: String, category: String = "Puppy") { self.osLog = OSLog(subsystem: label, category: category) super.init(label) } diff --git a/Sources/Puppy/Puppy.swift b/Sources/Puppy/Puppy.swift index c8bccc0..3785208 100644 --- a/Sources/Puppy/Puppy.swift +++ b/Sources/Puppy/Puppy.swift @@ -12,6 +12,8 @@ public class Puppy { public private(set) var loggers = Set() + public init() {} + public func add(_ logger: BaseLogger) { if !(loggers.contains(logger)) { loggers.insert(logger) diff --git a/Sources/Puppy/PuppyLogHandler.swift b/Sources/Puppy/PuppyLogHandler.swift index 4bb266d..51e5a64 100644 --- a/Sources/Puppy/PuppyLogHandler.swift +++ b/Sources/Puppy/PuppyLogHandler.swift @@ -19,7 +19,7 @@ public struct PuppyLogHandler: LogHandler { private let label: String private let puppy: Puppy - init(label: String, puppy: Puppy, metadata: Logger.Metadata = [:]) { + public init(label: String, puppy: Puppy, metadata: Logger.Metadata = [:]) { self.label = label self.puppy = puppy self.metadata = metadata