Skip to content

Commit

Permalink
Merge pull request #7 from marekpridal/6-add-support-for-database-cat…
Browse files Browse the repository at this point in the history
…egory

Add support for database category
  • Loading branch information
marekpridal authored Oct 16, 2022
2 parents e0eb920 + 80e06e6 commit f2c1606
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set Xcode version
run: sudo xcode-select --switch /Applications/Xcode_12.app

- name: Generate Xcode project
run: swift package generate-xcodeproj

Expand Down
19 changes: 9 additions & 10 deletions Sources/LogKit/LogKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,19 @@ import StoreKit

@available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
public enum Log {
public enum Category: String {
public enum Category: String, CaseIterable {
case `deinit`
case function
case networking
case `default`
case expiration
case inAppPurchase
case error
case database
}

public static var subsystem = Bundle.main.bundleIdentifier!
public static var enabledLogging: [Category] = [
.deinit,
.function,
.networking,
.default,
.expiration,
.inAppPurchase,
.error
]
public static var enabledLogging: [Category] = Category.allCases

public static func `deinit`(of object: AnyObject) {
guard enabledLogging.contains(.deinit) else { return }
Expand Down Expand Up @@ -116,6 +109,12 @@ public enum Log {
os_log("%{PRIVATE}@", log: deinitLog, type: .error, error.localizedDescription)
}

static func database(_ string: String) {
guard enabledLogging.contains(.database) else { return }
let log = OSLog(subsystem: subsystem, category: LogKit.Log.Category.database.rawValue)
os_log("%{PRIVATE}@", log: log, type: .debug, string)
}

@available(watchOS 6.2, *)
public static func products(request: SKProductsRequest) {
guard enabledLogging.contains(.inAppPurchase) else { return }
Expand Down

0 comments on commit f2c1606

Please sign in to comment.