Skip to content

Commit 571df9a

Browse files
authored
REM SwiftyBeaver, MOD minimum deployment version set to iOS 14, ADD OSLog (#33)
* REM SwiftyBeaver, MOD minimum deployment version set to iOS 14, ADD OSLog for logging. * REM SwiftyBeaver dependencies from SPM & CocoaPods
1 parent 73a5141 commit 571df9a

File tree

9 files changed

+83
-131
lines changed

9 files changed

+83
-131
lines changed

GirdersSwift.podspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Pod::Spec.new do |s|
2424

2525

2626
s.source_files = 'Sources/GirdersSwift/**/*.{swift}'
27-
s.dependency 'SwiftyBeaver', '1.9.5'
2827
s.dependency 'KeychainAccess', '4.2.2'
2928
s.dependency 'PromiseKit', '6.17.1'
3029
s.frameworks = 'Foundation', 'Security'

Package.resolved

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@ import PackageDescription
66
let package = Package(
77
name: "GirdersSwift",
88
platforms: [
9-
.iOS(.v12)
9+
.iOS(.v14)
1010
],
1111
products: [
1212
.library(
1313
name: "GirdersSwift",
1414
targets: ["GirdersSwift", "GRSecurity"]),
1515
],
1616
dependencies: [
17-
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver.git", exact: "1.9.5"),
1817
.package(url: "https://github.com/mxcl/PromiseKit.git", exact: "6.17.1"),
1918
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", exact: "4.2.2"),
2019
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", exact: "9.0.0")
2120
],
2221
targets: [
2322
.target(
2423
name: "GirdersSwift",
25-
dependencies: ["SwiftyBeaver", "PromiseKit", "KeychainAccess"]),
24+
dependencies: ["PromiseKit", "KeychainAccess"]),
2625
.binaryTarget(
2726
name: "GRSecurity",
2827
path: "Sources/GRSecurity.xcframework"
@@ -31,7 +30,6 @@ let package = Package(
3130
name: "GirdersSwiftTests",
3231
dependencies: [
3332
"GirdersSwift",
34-
"SwiftyBeaver",
3533
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")
3634
],
3735
resources: [

Podfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ source 'https://cdn.cocoapods.org/'
55
use_frameworks!
66

77
target :GirdersSwift do
8-
pod 'SwiftyBeaver', '1.9.5'
98
pod 'PromiseKit', '6.17.1'
109
pod 'KeychainAccess', '4.2.2'
1110
end
1211

1312
target :UnitTest do
14-
pod 'SwiftyBeaver', '1.9.5'
1513
pod 'OHHTTPStubs/Swift', '7.0.0'
1614
end
1715

Sources/GirdersSwift/config/ConfigUtil.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,15 @@ public func loadConfig(fromResource resource: String, bundle: Bundle = Bundle.ma
99
let resource = resource as NSString
1010
let filename = resource.lastPathComponent as NSString
1111
let url = bundle.url(forResource: filename.deletingPathExtension,
12-
withExtension: resource.pathExtension)
12+
withExtension: resource.pathExtension)
1313

14-
guard let pathUrl = url else {
15-
return [:]
16-
}
14+
guard let pathUrl = url,
15+
let data = try? Data.init(contentsOf: pathUrl),
16+
let dict = try? PropertyListSerialization.propertyList(from: data,
17+
options: [],
18+
format: nil) as? [String : Any] else { return [:] }
1719

18-
do {
19-
let data = try Data.init(contentsOf: pathUrl)
20-
let dict = try PropertyListSerialization.propertyList(from: data,
21-
options: [],
22-
format: nil) as? [String : Any]
23-
return dict ?? [:]
24-
} catch {
25-
Log.error("error loading configuration")
26-
return [:]
27-
}
20+
return dict
2821
}
2922

3023
/// Returns the plist path as a string for a given resource and bundle.

Sources/GirdersSwift/util/Log.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
enum LogLevel: Int {
2+
3+
case debug = 0
4+
case info = 1
5+
case error = 2
6+
case fault = 3
7+
8+
}
9+
10+
extension LogLevel: Comparable {
11+
12+
static func < (lhs: LogLevel, rhs: LogLevel) -> Bool {
13+
lhs.rawValue < rhs.rawValue
14+
}
15+
16+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import OSLog
2+
3+
public var Log = Logging()
4+
5+
6+
/// Logger class implementing the LogProtocol.
7+
public class Logging {
8+
9+
let logger = Logger(subsystem: "com.github.GirdersSwift", category: "GirdersSwift")
10+
let thresholdLevel: LogLevel = {
11+
guard let rawLogLevel = Configuration.sharedInstance[Constants.LogLevel] as? Int,
12+
let level = LogLevel(rawValue: rawLogLevel) else {
13+
return .debug
14+
}
15+
return level
16+
}()
17+
18+
public func debug(_ message: String) {
19+
log(.debug, message)
20+
}
21+
22+
public func info(_ message: String) {
23+
log(.info, message)
24+
}
25+
26+
public func error(_ message: String) {
27+
log(.error, message)
28+
}
29+
30+
public func fault(_ message: String) {
31+
log(.fault, message)
32+
}
33+
34+
}
35+
36+
private extension Logging {
37+
38+
func log(_ level: LogLevel, _ message: String) {
39+
guard level >= thresholdLevel else {
40+
return
41+
}
42+
logger.log(level: level.osLogType, "\(message)")
43+
}
44+
45+
}
46+
47+
private extension LogLevel {
48+
49+
var osLogType: OSLogType {
50+
switch self {
51+
case .debug: return .debug
52+
case .info: return .info
53+
case .error: return .error
54+
case .fault: return .fault
55+
}
56+
}
57+
58+
}

Sources/GirdersSwift/util/SwiftyBeaverLogger.swift

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)